• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to create a substitution variable in VBA

thalacker

New Member
I'd like help with substituting range in a VBA script I've written, the Script is below. I'd like to enter "21:24" one time at the beginning of the script. Once I understand how to enter the value/range in the script, I'd like to be able to be prompted for it. THANKS!

>>> use code - tags <<<
Code:
Sub insert rows()

Worksheets("January").Range("21:24").EntireRow.Insert
Worksheets("February").Range("21:24").EntireRow.Insert
Worksheets("March").Range("21:24").EntireRow.Insert
Worksheets("April").Range("21:24").EntireRow.Insert
Worksheets("May").Range("21:24").EntireRow.Insert
Worksheets("June").Range("21:24").EntireRow.Insert
Worksheets("July").Range("21:24").EntireRow.Insert
Worksheets("August").Range("21:24").EntireRow.Insert
Worksheets("September").Range("21:24").EntireRow.Insert
Worksheets("October").Range("21:24").EntireRow.Insert
Worksheets("November").Range("21:24").EntireRow.Insert
Worksheets("December").Range("21:24").EntireRow.Insert
Worksheets("October").Range("21:24").EntireRow.Insert

End Sub
 
Last edited by a moderator:

Debaser

Well-Known Member
For example:

Code:
dim RowNumbers as String
RowNumbers = Inputbox("Enter row numbers - eg 21:24)
if rownumbers <> "" then
Worksheets("January").Range(rownumbers).EntireRow.Insert
Worksheets("February").Range(rownumbers).EntireRow.Insert
...
End If
 
Top