ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using variables for row index (https://www.excelbanter.com/excel-programming/281405-using-variables-row-index.html)

NYIT

Using variables for row index
 

Hello,

Working with Visual Basic I am trying to insert a row at a point in an
excel spreadsheet. This point will constantly change depending on other
information. Now I know the code to do this is

Rows("42:42").Select
Selection.Insert Shift:=xlDown

and I have a variable k dimensioned as an integer and its value set to
the number of rows down that I want the new row to be inserted in.
Everyway that I have tried to place this integer in it has not worked.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


Harald Staff

Using variables for row index
 
Sub test()
Dim R As Long
R = 42
Rows(R).Insert
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please

"NYIT" skrev i melding
...

Hello,

Working with Visual Basic I am trying to insert a row at a point in an
excel spreadsheet. This point will constantly change depending on other
information. Now I know the code to do this is

Rows("42:42").Select
Selection.Insert Shift:=xlDown

and I have a variable k dimensioned as an integer and its value set to
the number of rows down that I want the new row to be inserted in.
Everyway that I have tried to place this integer in it has not worked.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 05:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com