ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range varying in for loop (https://www.excelbanter.com/excel-programming/331996-range-varying-loop.html)

McManCSU

Range varying in for loop
 

Basically I want to be able do something like this:

Range("A&initialrow : B&initialrow").Select
and
Selection.AutoFill Destination:=Range("A&initialrow-1 : B&x"),
Type:=xlFillCopy

where they are both in a for loop and 'x' is the incremental value, and
initialvalue is some constant. Im sure I just have sytax wrong, but I
cant find anything like it. Thanks!


--
McManCSU
------------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...o&userid=24379
View this thread: http://www.excelforum.com/showthread...hreadid=379708


bhofsetz[_22_]

Range varying in for loop
 

You need to separate your variables and text fully with quotes and &


Code:
--------------------
Range("A" & initialrow & ":B" & initialrow).Select

Selection.AutoFill Destination:=Range("A" & initialrow-1 & ":B" & x), Type:=xlFillCopy
--------------------


Make sure you keep the spaces between the " and the & and your
variable. The VBA editor doesn't like it when there are no spaces
surrounding the connecting &

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=379708



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

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