1. The code to change the value of each cell of the name range at the same time
Sub Change_the_Value_of_Each_cell_in_Named_Range()
Dim NameRange As Range
Set NameRange = Range("SALES")
Dim Eachcell As Range
For Each Eachcell In NameRange
Eachcell.Value = "Sales" & "2017"
Next Eachcell
MsgBox "Done"
End Sub
2. Let's Say You have a list of Named Range in Sheet3 where you want to change the value of each Named Range with the Same Format
Sub Change_The_Value_of_Each_Named_Range()
Dim I As Long
I = 2
Dim SheetName As String
SheetName = "Sheet3"
Dim TargetRange As Range
Do Until Sheets(SheetName).Cells(I, 1).Value = vbNullString
Set TargetRange = Range(Sheets(SheetName).Cells(I, 1).Value)
TargetRange.Value = Sheets(SheetName).Cells(I, 1).Value & VBA.Format(Sheets(SheetName).Range("B6").Value, "YYYY")
I = I + 1
Loop
End Sub
3. TO RENAME THE WHOLE NAMED RANGES with EXACT FORMAT
Sub Rename_The_Name_Range()
Dim SheetName As String
SheetName = "Sheet3"
Dim TargetSheet As Worksheet
Set TargetSheet = Sheets(SheetName)
Dim TargetNamedRange As Name
Dim CurrentName As String
Dim Iname As String
Dim OriginalNamePlace As Integer
Dim HelperString As String
For Each TargetNamedRange In ThisWorkbook.Names
Iname = TargetNamedRange.Name
If VBA.InStr(1, Iname, "_") = 0 Then
CurrentName = Iname & VBA.Format(VBA.Date, "_yyyy")
ThisWorkbook.Names(Iname).Name = CurrentName
Else
OriginalNamePlace = VBA.InStr(1, Iname, "_")
HelperString = VBA.Left(Iname, OriginalNamePlace - 1)
CurrentName = HelperString & VBA.Format(VBA.Date, "_yyyy")
ThisWorkbook.Names(Iname).Name = CurrentName
End If
Next TargetNamedRange
MsgBox "Done"
End Sub
Showing posts with label MACRO. Show all posts
Showing posts with label MACRO. Show all posts
Tuesday, November 27, 2018
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.
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.
Subscribe to:
Posts (Atom)
IsValidPasswordString Function
'Following function will verify if the password string contains following characters or not? Rem : List of Characters Group - ASCII Rem ...
-
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 teac...
-
Hello Mates, When you work with Userform in Excel VBA, usually sometimes you need to retrieve or reflect currency figure in the Userfo...
-
Making VBA Development Version Independent, will require focussed research and I think it's still "long" to go... ( Here ...