Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Unknown Range in Macro

Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Unknown Range in Macro

Tell us more. Do you want to set the range or just the last row of this
range.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"scone57" wrote in message
...
Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Unknown Range in Macro

I am not sure of the range as it will change monthly, so cant set it,but at
the moment the column states FALSE, when there is no data in the previous
columns.

"Don Guillett" wrote:

Tell us more. Do you want to set the range or just the last row of this
range.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"scone57" wrote in message
...
Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Unknown Range in Macro

More info please! If a column is stating FALSE, do you want to select the
column? Or the column before/after? Which rows?
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"scone57" wrote:

I am not sure of the range as it will change monthly, so cant set it,but at
the moment the column states FALSE, when there is no data in the previous
columns.

"Don Guillett" wrote:

Tell us more. Do you want to set the range or just the last row of this
range.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"scone57" wrote in message
...
Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Unknown Range in Macro

What controls your variable? (what logic?) Assuming you already have that
part figured out, and you want to fill to row xCount (xCount being your
variable) you could change your script to

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R" & xCount)
Range("R4:R" & xCount).Select

Other ideas for your variable, depending on the logic you want, would be to
count cells and set this value equal to xCount, or have xCount equal the
value of some cell in the spreadsheet. (ie, xCount = Range("a1").value )

--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"scone57" wrote:

Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default Unknown Range in Macro

First you should tell us how do you want to determine the range limits. E.G
if you can determine the last used row as the end of the range then

lastrow = Range("A" & Rows.Count).End(xlUp).Row

Selection.AutoFill Destination:=Range("R4:R" & lastrow)


Regards,
Stefi

€žscone57€ť ezt Ă*rta:

Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Unknown Range in Macro

hi
key would be to find the last row in your range and assign it to a variable.
maybe....
Dim lr As Long
lr = Cells(Rows.Count, "R").End(xlUp).Row

then plug in....
Range("R4").AutoFill Destination:=Range("R4:R" & lr)
Range("R4:R" & lr).Select

regards
FSt1

"scone57" wrote:

Having trouble changing a fixed range to a variable range in VBA.
When creating the macro, I used a fixed range, but now need to change this
to a variable, for future spreadsheets.

Range("R4").Select
Selection.AutoFill Destination:=Range("R4:R886")
Range("R4:R886").Select

Can anyone help?

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
Counting an Unknown Range atryon Excel Discussion (Misc queries) 1 May 5th 08 08:44 PM
sorting unknown range peyman Excel Discussion (Misc queries) 10 October 20th 07 08:34 PM
HELP! Unknown range Excel_Oz Excel Worksheet Functions 3 March 16th 07 01:35 AM
Sumproduct (Range unknown, needs Search) ExcelQuestion Excel Worksheet Functions 8 May 3rd 06 07:24 AM
Average of Unknown Range Mike Excel Discussion (Misc queries) 9 March 24th 06 03:37 PM


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

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"