Friday, March 30, 2018

How to start Excel VBA Programming ?

Question:

Hi All! I considered myself an advanced user until I learned there was an entire world of VBA out there. So now I’m trying to teach myself. This group is an amazing resource. Thanks to all that contribute!

Question: Does anyone have a specific method or process in planning an Excel project?

I’m finding there’s so much you can do and I end up getting lost down rabbit holes. I decided to start with designing the visual aspect of UserForms first then figuring out how to make them work later. I’m not sure that is the best way.

Hopefully, my question makes sense. Thanks for any and all feedback!


===========

Answer:

Let's begin with the home.. :)
Before a Six month ago, I was in your place. But, I have decided to learn VBA anyhow. I'm an Engineer BUT, I was too much far from the world of programming.
I started learning VBA by Recording A Macro. Yes,
there are two features available in Microsoft Excel to do an automation task.
I used to record macros and see how it coded. I took little help from my cousin who knows VBA programming. He challenged me with the little tasks.
task Like,
Copy every time the cell value of A1 of sheet1 to Cell A1 of sheet2
So, that's how it begins for me.
We are all for you as my Cousin brother was for me!
And one more important point to remember.
whenever you feel just little in the amount that, you can write little codes on your own. Then go for the bigger project to develop. and challenge your self to develop each and every idea of yours regarding your dreaming application.

1. First, design your idea.
2. Write down the functionality of your dream application.
3. Make the design on paper that, how it will look
4. Make the design on paper that, how it will work.
5 Finally, think about how I will code this damn!

And we are always here for all of our group members.
thank you and all the best.

Wednesday, March 28, 2018

Enter Query in Column(A) and get the result in Column(B) by Lookup function using VBA

Question :

Please, you can help me with one VBA Code which is able to extract from two columns A, B....B value. But how?

If I have database în sheet 2:


(col.A) 1. Jhon..... 30 years old(col. B)
(col.A) 2. James..... 32 years old(col. B)
(col.A) 3. Bob..... 35 years old(col. B)
.............................................................
(col.A) n. John..... 39 years old(col. B)

And I want în sheet 1:

When I type în col.A for ex: "James", în col.B gives "32 years old".....then aleatory typed "John" în col.A and în col B give "39 years old" etc.

Can you help me with that VBA Code?

Thank you,


Solution: 

Let's first making our Database Dynamic.

Sheets("date") has the data which you want to look into for your query.

1. Go to Ribbon --> Formulas --> Name Manager --> Click on button NEW
2. in New box, you are asking for new range details.
3. The name is as "Database"
4. Now, in "referes to": paste the following formula and save it and close that.

=OFFSET(date!$A$2,0,0,COUNTA(date!$A:$A)-1,2)

5. now, open VBA Compiler
6. Open Project Window
7. under Microsoft Excel Objects find the Sheet where you want to insert the query and get the result in the same.

In your case, Sheets("vlookup") is your query sheet.

8. Click on Sheet1(vlookup) and the coding area will be open up.
9. Now you want to change the value automatically after entering the value in the specific cell, So, in this case, we required "Worksheet_Change" procedure to fire up the result.
10. Select the Worksheet Object and then select the "Change" Procedure
11. You will get the,

Private Sub Worksheet_Change(ByVal Target As Range)
End Sub

Now insert the following code in between above two lines.
=======================
If Target.Column = 1 Then
Application.EnableEvents = False
With THEVL.Sheets("vlookup")
.Activate
.Select
.Cells(Target.Row, 2).Value = "=IFERROR(VLOOKUP(A" & Target.Row & ",Database_v,2,FALSE),0)"
End With
Application.EnableEvents = True
End 
========================
==
12. Save the Excel and restart the application.
13. Try to add something to anywhere in Column(A) of a sheet("vlookup"). you will get the result in adjacent to the cell.

I hope it helps you and other folks.

Thank you.
- Kamal Bharakhda












IsValidPasswordString Function

'Following function will verify if the password string contains following characters or not? Rem : List of Characters Group - ASCII Rem ...