View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Wart Wart is offline
external usenet poster
 
Posts: 19
Default Macro (I Think) To Update List in Workbook With Weekly Updates

I just got out an interminable meeting this morning and saw your email. I
tried the code immediately, and it works WONDERFULLY! Oh, my God--this is
EXACTLY what I needed! Thank you so much, Dave! You've just saved me (and
others) probably hundreds of hours of totally meaningless report-trowling
every year. I'll nominate you in absentia for the Initech Star of the Month
award.

Again--you truly have made the lives of some cubemoles in Ohio a whole lot
better. Thank you!



"Dave" wrote:

Hi,
Yeah, being a Kiwi in Brazil is pretty good - but I've never been to Ohio.

Ok, try this code. Copy and paste it into a module in the VBA window.

Sub Update()
Dim A As Integer, ML As Integer, UL As Integer
ML = 2 'MasterList Start Row
UL = 2 'UpdateList Start Row
Do Until Sheets("Sheet2").Cells(UL, 1) = ""
Do Until Sheets("Sheet1").Cells(ML, 1) = ""
If Sheets("Sheet1").Cells(ML, 1) = Sheets("Sheet2").Cells(UL, 1) Then
Worksheets("Sheet2").Activate
Sheets("Sheet2").Range(Cells(UL, 1), Cells(UL, 12)).Copy _
Sheets("Sheet1").Cells(ML, 1)
ML = 2
Exit Do
End If
ML = ML + 1
If Sheets("Sheet1").Cells(ML, 1) = "" Then
Worksheets("Sheet2").Activate
Sheets("Sheet2").Range(Cells(UL, 1), Cells(UL, 12)).Copy _
Sheets("Sheet1").Cells(ML, 1)
End If
Loop
UL = UL + 1
ML = 2
Loop
End Sub

For this to work, you will have to copy and paste the update data into a new
sheet in the same workbook as the Master List. I have assumed that this new
sheet tab name will be Sheet2. If not, you will have to change the 6
instances of Sheet2 in the code to the new tab name in your workbook.

I have assumed that your Master List tab name is Sheet1. If this is not so,
you will have to change the 5 instances of Sheet1 in the code to the name of
your Master List sheet tab.

One more assumption: That you have headers in Row 1, and that the data
actually starts in Row 2, for both the Master List and the Update List. If
this is not so, you will need to change the numbers in the following code:
ML = 2
UL = 2

However, I very strongly recommend that you do all this on a copy of your
Master List workbook first, until you are content that it works (and doesn't
just transfer all the odd fractions of cents into your bank account.) On your
copy, rename the Master List sheet tab to Sheet1, and copy the update data
into Sheet2 so you don't have to change any code right away.

Hope this works for you. If there's lots of data, it may take a few seconds
to run. Let me know.
Regards - Dave.