Archive

Archive for the ‘Posts’ Category

Excel : Form to Save Data P-1

March 31, 2020 Leave a comment


Learning : VBA Codes to Save Data
Subject: Create Form to collect Data

In a very fast and as simple as we can, we will design and write VBA codes to transform three fields of Data from an Excel sheet “Form” to another sheet “Data”.

To keep thing as simple as we can, we will not use any Validations on user inputs in this example.


First, we will re-name a sheet to “Form” and another one to “Data”. In sheet [Form] we will create a simple Form to collect Names, Company Name and Emails of our customers, also we add a button and call it Save. As in Image-1

Image-1


For companies Name, We will create a list then we will link it to Cell”D9″ so we can select a “Company Name” from a drop-down list. So to do this First in the Data sheet I will write a list of companies Name as (Comp Name 1,Comp Name 2,Comp Name 3, …. to Comp Name 10). I start my list from Cell “H8” [As in Image-2] you may start from any Cell you want.

Image-2


Now to link a Dropdown list of our companies Name to Cell “D9″ Do this:
1. Goto Cell”D9”.
2. From the menu we will select “Data” then “Data Validation” and select Data Validation. [Image-3]

Image-3


3. In the Allow [Select “List”], then in the Source we select the range of Companies we write [Range Cells H8:H17] or just write this: =$H$8:$H$17. Then click OK. See Image-4

Image-4

Now if we try to click on Cell “D9” we will have a list as in Image-5.

Image-5

In the “Data” Sheet we will just create the Table Header as in Image-6, and will go-back to “Form” Sheet.

Image-6


Now we will write the VBA codes and link it to to a “Save” Button we create. To open the Visual-Basic window we select “Developer” From the Top menu, then Press Visual Basic.

Then we write this code and link it to the Save Button. ..

 # VBA Macro code to Save Data to Data sheet 

Sub Save_data()
'
' Save_data Macro
' Macro recorded 2020-03-29 by HP
'

'
    ' Set Variables
    Name = Range("D7").Value
    comp_name = Range("D9").Value
    Email = Range("D11").Value


    ' Goto data sheet
    Sheets("Data").Select
    ' This line will get the Next empty Row in the Data sheet.
    emp_row = Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    Range("A" & emp_row).Value = Name
    Range("B" & emp_row).Value = comp_name
    Range("C" & emp_row).Value = Email
   
    'Go to Form Sheet.
    Sheets("Form").Select
   
    ' Clear data cells.
    Range("D7").Value = ""
    Range("D9").Value = ""
    Range("D11").Value = ""
   
    Range("D7").Select
   
End Sub



Now if we enter some data [as we said: No Validation on the data] and press the Save button, the data will be coped to next empty row in the Data Sheet.



Enhancement: In some cases as in our coming project, it’s better to create a sheet and call it “Setting”, then we can have our Lists (such as Company-Name), Colors, Filters all to be in the Setting sheet. [We will see this in the Next Project.]



Follow me on Twitter..




By: Ali Radwani




Python: Cooking App P-5

February 13, 2020 Leave a comment


Learning : Python, Data-Base, SQlite
Subject: Writing a Cooking Application

RECIPES MENU: Once I start reading the Net (blogs and Cooking Books) to see how cookers talking about foods-recipes, I realise that I may need to add something to the DataBase, then I start writing the codes for the “Recipe Menu” and immediately I find the we need to add a new Table; I call it “recipes_steps” it will hold several steps of how to cook a recipe.

DataBase Diagram

Here is the code to create the new Table and adding the record 0 (Zero).
# To create the Table “recipes_steps” .
sql_recipes_steps =”CREATE TABLE if not exists recipes_steps (st_id INTEGER PRIMARY KEY AUTOINCREMENT,r_id integer, rec_steps text )”
c.execute(sql_recipes_steps)
db_conn.commit()

# To add the Record Zero.
c.execute (“INSERT INTO recipes_steps (st_id) VALUES(:st_id)”,{“st_id”:0})
db_conn.commit()

First let’s see the “Recipe Menu” and from there we will write the codes for each item in the menu. As we saw in Ingredients Menu, same functionality should be here to, Listing all Recipes, Adding new one, Editing and Deleting a recipes. We will write the code for each of them, and here is the code for the “Recipes Menu”

 # Recipes Menu - Function
 
def recipes_menu ():
    while True:
        os.system("clear")
        print('\n ===========[ RECIPES MENU ]=============')
        print('  --------------------------------------')
        print(' 1. Show Recipes.')
        print(' 2. Add Recipe.')
        print(' 3. Delete Recipe. ')
        print(' 4. Edit Recipe.')
        print(' 9. Exit')
        uinp= input('\n Enter your Selection: ')

        if uinp == '1':
            show_recipes()
        elif uinp == '2':
            add_recipe()
        elif uinp == '3':
            del_recipe()
        elif uinp == '4':
            edit_recipe()
        elif uinp =='9':
            return
        else:
            print('\n  Please select from the Menu.')


So first thing we will work on “Show Recipes”, once the user select Show Recipes another Menu will be display to give more option as in the screen shot..

To display the Recipes based on the options we have, we will write a function that take a parameter based on the user selection so the user can search for a recipe based on it’s Name, Date or other details. Let’s see the code ..



NOTE THAT: We did nothing with Tags option, after we finish the application we will assume that the Business owner ask to add a new requirement to the application, and we will see the impact of this and who to solve it.


In Next Post we will work on the Adding New Recipe to our Cooking Application.



To Download my Python code (.py) files Click-Here




Follow me on Twitter..




By: Ali Radwani




Elephant Sketch

March 5, 2015 4 comments


Here are another Sketch of Elephant face, most of my sketches are from photos I fond in magazines or news-paper or the internet. For this sketch I am using Samsung Galaxy Note3 and Sketchbook Application, but i am using Note 8 and paper with Pen, Ink-pen or pencil.

Other sketches are on My-Sketch page, or you can Follow me on instagram for more sketches.

Sketch153105750




::Sketching::
Using: Galaxy Note 3
Application: Sketchbook



Follow me on Twitter..


Inst_icon




Ali,

The Schwanenburg

February 21, 2014 Leave a comment



A Germany stamp Issued in 1978 showing the “Schwanenburg” in brown color, this photo is one of my stamps collection, I am using the Nikon D90 camera and the Nikon 35mm lens in a homemade studio.




















For more photos of Germany Stamps Click Here



Follow me on Twitter..



Ali,

The First Issue

December 18, 2013 Leave a comment


This is the First Issue of Qatari Stamps of the New Emir (Ruler H.H. Sheikh Tamim bin Hamad Al Thani), the set consist of 9 grouped stamps (Denomination: 30QR, 20QR, 10QR, 5QR, 4QR, 3QR, 2QR, 1QR and 50DIRHAMS) the set issued in the occasion of the National Day 18-Des-2013. Click Here to see all the set


المجموعه الاولى لطوابع بريديه تحمل صور الشيخ تميم بن حمد آل ثاني وقد تم اصدارها بمناسبة اليوم الوطني “قلوبنا موارد عزنا” وهي تتالف من 9 فئات


اضغط هنا للمزيد

This is the set.
DSC_4795 copy

























This is the Studio, I use the Neewer TT520 flash connected to the camera via TTL cable, Nikon D7100 and Nikkor 18-300mm, the circle in the image represent the camera position. all the photos been resized and croped in photoshop.

DSC_4786 copy






















::Camera Setting::
Camera: Nikon D7100
F-number: f/8
Exposure: 1/400sec.
ISO:200
Lens: Nikon 18-300m @ 195m



Follow me on Twitter..



Ali,

UAE 1975 4th NATIONAL DAY..

December 7, 2012 Leave a comment



This Stamp is one of the set of the “UAE 1975 4th NATIONAL DAY”, I think the stamp is for H.H. Hamad bin Mohammed Al Sharqi ruler of the Emirate of Fujairah in the United Arab Emirates (UAE).the stamp is one of my collection of the UAE Stamps Click Here to see all posted collection.


[Click to Enlarge]




Follow me on Twitter..




Ali,

Kleiber Bird, Stamp from Germany

August 27, 2012 Leave a comment



Issued in 1979-01-09 in Germany, this is one of my stamps from Germany showing one of the birds. This shot is part of my project “Stamp Photography”, more photos Click Here.


مشروع تصوير الطوابع البريديه، كاميرا نيكون دي90 عدسة نيكون 35مم اضاءه فلورسنت الغرفه
طوابع خليجية على هذا الرابط



[Click to Enlarge]













Camera: Nikon D90
Lens: Nikon 35mm




Follow me on Twitter..



Ali,