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

I'm having trouble modifying a line of code. As shown the code selects the
data in columns A:C from row 2 down the the last row with data in A. This
work fine.

Worksheets("Sheet1").Range("A2:C" & Range("A2").End(xlDown).Row).Select

Here's my problem. I need to keep offsetting this calculation by 4 columns
using an integer n. If n=1, the code is as above. If n=2, the code should
select the data in columns E:G from row 2 down the the last row with data in
E (that very last part about E is where I'm stuck).

I'd be grateful for help with this
Bri







  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Offset concern

not sure what you mean, is this anywhere near what you want?

Dim lastrow As Long

Sub test()
lastrow = Cells(Rows.Count, Range("a2").Value).End(xlUp).Row
Worksheets("Sheet1").Range(Cells(2, 1 + Range("A2")), Cells(lastrow, 2 + _
Range("a2"))).Select
End Sub
--


Gary


"Bri" wrote in message
...
I'm having trouble modifying a line of code. As shown the code selects the
data in columns A:C from row 2 down the the last row with data in A. This
work fine.

Worksheets("Sheet1").Range("A2:C" & Range("A2").End(xlDown).Row).Select

Here's my problem. I need to keep offsetting this calculation by 4 columns
using an integer n. If n=1, the code is as above. If n=2, the code should
select the data in columns E:G from row 2 down the the last row with data in E
(that very last part about E is where I'm stuck).

I'd be grateful for help with this
Bri









  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Offset concern

Hi Bri,
Or this?
Dim n As Integer
For n = 0 To 5
Worksheets("Sheet1").Range("A2:C" & Range("A2"). _
End(xlDown).Row).Offset(0, n * 4).Select
Next

Which I guess does what you want for 4 offsets.

Ken Johnson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Offset concern

Ken - Yes, that's it exactly. I had the 'offset' and the 'end' in the wrong
places.
Thanks, Bri

"Ken Johnson" wrote in message
oups.com...
Hi Bri,
Or this?
Dim n As Integer
For n = 0 To 5
Worksheets("Sheet1").Range("A2:C" & Range("A2"). _
End(xlDown).Row).Offset(0, n * 4).Select
Next

Which I guess does what you want for 4 offsets.

Ken Johnson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Offset concern

Hi Bri,
You're welcome, thanks for the feedback.
Ken Johnson



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
Header concern Bri[_3_] Excel Programming 3 March 12th 06 03:45 AM
Page Header concern Bri Excel Worksheet Functions 3 January 30th 06 03:28 PM
sorting concern Giselle Excel Worksheet Functions 2 January 27th 06 06:08 PM
hidden column concern Bri Excel Worksheet Functions 3 January 23rd 06 04:26 AM
Toggle Button Updating Concern Jim Thomlinson[_3_] Excel Programming 3 April 14th 05 01:42 AM


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