compiling worksheets in excel

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
TommyJ
Newbie
Posts: 11
Joined: Tue Sep 30, 2003 8:59 pm

compiling worksheets in excel

Post by TommyJ » Tue Oct 21, 2003 7:14 pm

This might be the wrong place to ask this so maybe i'm just asking for a direction to go in. I need to update a worksheet in excel from other worksheets in the same book.

basically, worksheet one should be all the rows from worksheets 2 through 5 which are updated once in a while. i think i can program the control button that runs the update from excel myself.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Oct 22, 2003 2:24 am

Don't need Macro Scheduler to do that, so this is probably not the correct forum. But since you are here, try this:

:idea: It's been years since I have done that, but you should be able to use Excel to roll up the cells in the other sheets to a top level sheet. Formula in spreadsheet1, cell A5 will look something like this:
=Sum(worksheet2:+A5,worksheet3:+A5,worksheet4:+A5,worksheet5:+A5)

After that formula is done correctly, just copy it to the other cells. Be sure to get the correct Relative and Absolute symbols before you copy to multiple cells.

Sorry if my syntax is not correct, but this should get you pointed in the correct direction.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

TommyJ
Newbie
Posts: 11
Joined: Tue Sep 30, 2003 8:59 pm

Post by TommyJ » Wed Oct 22, 2003 1:44 pm

thanks, i actually found this bit of vba that does almost exactly what i want. The problem is that i don't want it to overwrite the last column on the "merged" worksheet. How can i leave that last column static?

Sub WSMerge()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
Application.ScreenUpdating = False
Set DestSh = Worksheets("Merged")
Worksheets("Merged").UsedRange.Offset(4, 0).ClearContents
For Each sh In Sheets(Array("Sheet2","Sheet3"))
Last = LastRow(DestSh)
sh.UsedRange.Offset(4, 0).Copy DestSh.Cells(Last + 1, 1)
Next
Application.ScreenUpdating = True
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
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("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function

Thanks for your help though

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts