LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default Offset in for loop not working

I am having a hard time coppying multiple columns with unknown lengths to
different worksheets and then naming the worksheets with the column headers.
I keep getting the global error when I try to offset the "startspot" or
"startname" to move to the next column. There has to be an easier way or I'm
missing something. Any suggestions?

My current code is as follows:

Dim startspot As Range, startsheet As Integer, personal As Range, startname
As Range

'Range("B5").Name = "startspot"
startsheet = 1
Set startname = Range("B5")
Set startspot = Range("B5")

For i = 1 To glcount

'Go to correct workbook and select all entries in given column and copy
Windows("New Workbook Formatting").Activate
Sheets("Printers").Range("startspot").Select
With Worksheets("Printers").Range("startspot")
Numpersonal = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
End With

Set personal = Range("startspot")
personal.Offset(1).Resize(Numpersonal, 1).Select
Selection.Copy

'Paste to new worksheet in CurrentCGAP and rename worksheet
Windows(CurrentCGAP).Activate
Sheets.Add
Range("A8").Select
ActiveSheet.Paste
ActiveSheet.Name = startname

'Move to next column and worksheet
Range(startspot) = Range(startspot).Offset(0, 1) 'error: Method
range of object failed global
startsheet = startsheet + 1
Range(startname) = Range(startname).Offset(0, 1) 'error: Method
range of object failed global


With ActiveSheet
.Move After:=Worksheets(Worksheets.Count)
End With

Next
 
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
offset not working BorisS Excel Discussion (Misc queries) 2 November 30th 05 08:15 AM
Loop with activecell.offset mthomas[_17_] Excel Programming 3 November 18th 05 09:29 PM
Need offset range for loop Joe Fish Excel Programming 8 October 17th 05 01:13 AM
Nested Loop Offset Glitch - Object required (Error 424) Arturo Excel Programming 1 November 21st 04 05:05 PM
Offset not working Ray Batig Excel Programming 2 December 30th 03 02:54 AM


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