Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 334
Default range function

This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" & SheetEnd).Select

The statement has to be as generic as possible.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default range function

Sub rick()
Dim SheetStart As Long, SheetEnd As Long
SheetStart = 3
SheetEnd = 11
Range("A" & SheetStart & ":D" & SheetEnd).Select
End Sub

--
Gary''s Student - gsnu200827


"Rick" wrote:

This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" & SheetEnd).Select

The statement has to be as generic as possible.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default range function

I'm not sure what your ultimate question is, but the range you asked about
appears to work fine (as long as you have assigned values to both SheetStart
and SheetEnd).

--
Rick (MVP - Excel)


"Rick" wrote in message
...
This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" &
SheetEnd).Select

The statement has to be as generic as possible.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default range function

Perhaps he means the first and last rows in ActiveSheet.UsedRange??

Sub rick()
Dim SheetStart As Long, SheetEnd As Long
Set r = ActiveSheet.UsedRange
SheetEnd = r.Rows.Count + r.Row - 1
SheetStart = r.Row
Range("A" & SheetStart & ":D" & SheetEnd).Select
End Sub

--
Gary''s Student - gsnu200827


"Rick Rothstein" wrote:

I'm not sure what your ultimate question is, but the range you asked about
appears to work fine (as long as you have assigned values to both SheetStart
and SheetEnd).

--
Rick (MVP - Excel)


"Rick" wrote in message
...
This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" &
SheetEnd).Select

The statement has to be as generic as possible.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default range function

Have you tried this which worked for me

Sub thisone()
sheetstart = 5
sheetend = 12
Range("A" & sheetstart & ":D" & sheetend).Select
End Sub


For some reason VBA seems to want the & to have spaces each side
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Rick" wrote in message
...
This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" &
SheetEnd).Select

The statement has to be as generic as possible.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default range function

This also works -- note the comma not semi-colon with the Range arguments

Sub onemore()
row1 = 5: col1 = 1
row2 = 12: col2 = 4
Range(Cells(row1, col1), Cells(row2, col2)).Select
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Rick" wrote in message
...
This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" &
SheetEnd).Select

The statement has to be as generic as possible.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 334
Default range function

I was trying to get it to execute, even after compiling. It is working now
in the original format. don't understand why it did not work earlier. Thanks
all for your help


"Bernard Liengme" wrote:

This also works -- note the comma not semi-colon with the Range arguments

Sub onemore()
row1 = 5: col1 = 1
row2 = 12: col2 = 4
Range(Cells(row1, col1), Cells(row2, col2)).Select
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Rick" wrote in message
...
This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" &
SheetEnd).Select

The statement has to be as generic as possible.




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default range function


Rick;189027 Wrote:
This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" &
SheetEnd).Select

The statement has to be as generic as possible.


Hello Rick,

The syntax is correct. What error are you getting?


--
Leith Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=52110

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default range function

This might work better

Range("A" & SheetStart & ":D" & Right(SheetEnd, 2)).Select




"Rick" wrote:

This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" & SheetEnd).Select

The statement has to be as generic as possible.

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default range function

This should do it. Since SheetEnd is apparently a cell address, it cannot be
used as a row reference.

Range("A" & SheetStart & ":D" & Range(SheetEnd).Row).Select



"Rick" wrote:

This example works Range("A3:F" & SheetEnd).Select...
How do I make this one work? Range("A" & SheetStart & ":D" & SheetEnd).Select

The statement has to be as generic as possible.



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
function range robert Excel Worksheet Functions 2 January 23rd 09 07:01 PM
dynamic range based on criteria, within a dynamic range, passed to a function [email protected] Excel Programming 5 October 9th 07 10:13 PM
creating a dynamic range based on criteria, within a dynamic range, and passing it to a function [email protected] Excel Programming 0 October 9th 07 05:22 PM
DBSUM function but with function as criterion, not a range corne_mo Excel Worksheet Functions 3 July 13th 07 12:20 PM
Translate range name passed as string to a custom function to range addresses! agarwaldvk[_25_] Excel Programming 3 September 7th 04 12:47 PM


All times are GMT +1. The time now is 06:25 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"