Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I can merge the worksheets with no problem, but on the worksheet I'm
updating from the others, there's a column at the end that gets overwritten every time and I want it to remain static. Any ideas? Here's the code I'm using for the merge which was gratefully clipped from http://www.rondebruin.nl/copy2.htm Private Sub CommandButton1_Click() 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).ClearCo ntents For Each sh In Sheets(Array("Sheet2", "Sheet3")) LastR = LastRow(DestSh) sh.UsedRange.Offset(4, 0).Copy DestSh.Cells(LastR + 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 ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
is the column in the sheet before any copying? If so, you woulr clear it
with Worksheets("Merged").UsedRange.Offset(4,0).ClearCo ntents You would need to use set rng = worksheets("Merged").UsedRange.Offset(4,0) Intersect(rng,worksheets("Merged").Columns(1).Resi ze(10)).Clearcontents Change the 10 to reflect the number of columns you want cleared starting from column A. -- Regards, Tom Ogilvy "TommyJ" wrote in message ... I can merge the worksheets with no problem, but on the worksheet I'm updating from the others, there's a column at the end that gets overwritten every time and I want it to remain static. Any ideas? Here's the code I'm using for the merge which was gratefully clipped from http://www.rondebruin.nl/copy2.htm Private Sub CommandButton1_Click() 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).ClearCo ntents For Each sh In Sheets(Array("Sheet2", "Sheet3")) LastR = LastRow(DestSh) sh.UsedRange.Offset(4, 0).Copy DestSh.Cells(LastR + 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 ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel merging and automatic edit of worksheets | Excel Worksheet Functions | |||
merging worksheets | New Users to Excel | |||
Merging Excel Worksheets | Excel Discussion (Misc queries) | |||
Merging worksheets into one | Excel Worksheet Functions | |||
Need help merging worksheets | Excel Discussion (Misc queries) |