Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Help make a macro variable

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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 846
Default Help make a macro variable

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

"Brad" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Help make a macro variable

It works for me whether 'r' is defined as Long or Integer.

Rick


"Brad" wrote in message
...
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

"Brad" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Help make a macro variable

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

Jim Thomlinson


"Brad" wrote:

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

"Brad" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a Chart with a Variable Data Window Jay Somerset Excel Discussion (Misc queries) 2 January 19th 07 04:41 PM
Can I make array position A(12) into a variable A(12*n) ? Paul Excel Worksheet Functions 1 October 9th 06 10:37 PM
Variable Macro Heather O'Malley Excel Discussion (Misc queries) 2 August 2nd 06 04:19 PM
how do I make single character as a variable in an array Hazlgrnguy Excel Worksheet Functions 1 September 25th 05 08:12 AM
make a vlookup using a variable path Alex St-Pierre Excel Worksheet Functions 1 March 2nd 05 11:54 PM


All times are GMT +1. The time now is 02:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"