Help make a macro variable

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

The following macro works - how can I make it so thate the numbers can be
variable.

Sub test3()
shtGPA9D.Rows("195:198").Insert
End Sub

I would like to have something like the following
Sub test3()
dim r as integer
r = 195
shtGPA9D.Rows(r:r+3).Insert
End Sub
 
Why does this work with "r" defined as long and not with integer?

Sub test3()
Dim r As Long
r = 195
shtGPA9D.Rows(r & ":" & r + 3).Insert
End Sub
 
It works for me whether 'r' is defined as Long or Integer.

Rick
 
The initial code posted Did not have the colon in Quotes. That's the
difference...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top