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: 4
Default Is there a "Set sourceRange =" for all sheets in workbook

Hello,

Is there a way to make
Set sourceRange = Sheets("Sheet1").Columns("D:D")
reference column D in all worksheets instead of just "Sheet1" ? I'm
looking for a global 'all sheets in workbook' command and can't seem to
find one. I realize that I can list all the sheets by individual name
Sheets(Array("Sheet2", "Main", "Control Sheet", "ZDV 08 FL270-359", _
"ZDV 08 FL270-369", "ZDV 08 FL270-379"))
OR
Sheets(Sheet2", "Main", "Control Sheet", "ZDV 08 FL270-359", _
"ZDV 08 FL270-369", "ZDV 08 FL270-379")
but I wanted to try and do this in one shot.

Any help is appreciated :-)
Thanks,
Bill

PS Here is the code that I found online and am trying to adapt to copy
column D from all sheets to a collection sheet where it will insert in the
next empty colum:
Sub CopyColumnew()
Dim sourceRange As Range
Dim destrange As Range
Dim Lc As Integer
Lc = Lastcol(Sheets("Main")) + 1
Set sourceRange = Sheets("Sheet1").Columns("D:D")
Set destrange = Sheets("Main").Columns(Lc)
sourceRange.Copy destrange
End Sub

Sub CopyColumnValues()
Dim sourceRange As Range
Dim destrange As Range
Dim Lc As Integer
Lc = Lastcol(Sheets("Main")) + 1
Set sourceRange = Sheets("Sheet1").Columns("D:D")
Set destrange = Sheets("Main").Columns(Lc). _
Resize(, sourceRange.Columns.Count)
destrange.Value = sourceRange.Value
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("D1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("D1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function

--
Message posted via http://www.officekb.com
 
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
Delete all sheets in workbook that contain "Dump" in the name Porr via OfficeKB.com Excel Worksheet Functions 2 May 19th 10 10:25 PM
Excel ignores "Sheets in new workbook" setting [email protected] Excel Discussion (Misc queries) 3 February 21st 09 10:11 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


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