LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Help in using an Offset in a .Range().Select

Thanks, Tom!

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Tom Ogilvy wrote:
If he wants to expand to the right I would suggest the following
modification:

With worksheet
.Range(.Range("A1"), .Range("A1").Offset(0,colTOright)).Select
End With


"Jake Marx" wrote in message
...
Hi roblo,

I didn't realize you were automating Excel from VBScript. Your
original syntax was correct, as you have a worksheet object variable
declared:

With Worksheet("Sheet1")
Range(.Range("A1"), .Range("A1").Offset(colTOright)).Select
End With


Should be:

With worksheet
Range(.Range("A1"), .Range("A1").Offset(colTOright)).Select
End With


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


roblo wrote:
Thanks Jake for the suggestion, but it does not work in my .VBS
script. Maybe in VBA?

colTOright = 6
' Create a new Excel workbook
set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = True
set workbook = objXL.Workbooks.Add
set worksheet = workbook.Worksheets("sheet1")
' worksheet.Range("A1:F1").Select
With Worksheet("Sheet1")
Range(.Range("A1"), .Range("A1").Offset(colTOright)).Select
End With

I'm just trying to replace the ending cell (F1) with a string or use
an Offset. Didn't think it would be that difficult.

newColumn = .Cells(A1).Offset(colTOright).Value
and replace F1 with newColumn, but that object doesn't except
strings.


worksheet.Range("A1:F1").Select

Robert

 
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
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM
Select row (with offset) from VB formula result RAP Excel Programming 1 August 7th 05 09:22 AM
How to Select a relative range with Using "Find" and Offset() Dennis Excel Discussion (Misc queries) 7 July 27th 05 03:57 PM
Select Range - using Offset ( 40 ,0 ) - not working Buffyslay Excel Programming 4 October 8th 04 11:35 AM
Select and Copy Range using Offset jondorv Excel Programming 1 May 16th 04 05:23 PM


All times are GMT +1. The time now is 03:34 AM.

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"