svendiamond
Well-known Member
- Joined
- Jun 13, 2014
- Messages
- 1,504
- Office Version
- 365
- Platform
- Windows
The point of this workbook I'm creating is to make an ugly system-generated report look nice. The user pastes the report onto the first page, then clicks a macro button that does everything. "Everything" includes deleting some columns to make it line up correctly, then copying and pasting the values to another sheet, yada yada yada.
I just need one more thing which is to Fill (up, not down) columns A, B, and C. I have a 2nd macro button on the final page that does this and works just fine. However, I would rather the user only have to click one button. So, I copied the code from this second button and added it to the end of my first button's code. But, now when I click the button, it only seems to run the first code. I don't get an error or anything... but the second code doesn't happen... it doesn't "fill up" those three columns.
I had that last part on the separate button and it worked just fine. But now it just doesn't do anything. Like I said, I don't get an error message. It just doesn't do what it's supposed to do (fill UP columns A/B/C). Thanks for any help you can provide.
I just need one more thing which is to Fill (up, not down) columns A, B, and C. I have a 2nd macro button on the final page that does this and works just fine. However, I would rather the user only have to click one button. So, I copied the code from this second button and added it to the end of my first button's code. But, now when I click the button, it only seems to run the first code. I don't get an error or anything... but the second code doesn't happen... it doesn't "fill up" those three columns.
Rich (BB code):
Private Sub CommandButton1_Click()
'
' ADJUST_REPORT Macro
'
' This first part formats the first sheet to align correctly
Range("C5:C46").Select
Selection.Delete Shift:=xlToLeft
Range("G5:G46").Select
Selection.Delete Shift:=xlToLeft
Range("I5:I46").Select
Selection.Delete Shift:=xlToLeft
Range("O5:O46").Select
Selection.Delete Shift:=xlToLeft
' So, now the first sheet is formatted and this part copies it and pastes it onto the next sheet:
Cells.Select
Selection.Copy
Worksheets("ADJUSTED").Visible = True
Sheets("ADJUSTED").Select
Sheets("ADJUSTED").Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Worksheets("ADJUSTED").Visible = False
' Now this will copy the "COPY THIS" sheet and paste it onto the "FINAL" sheet
Worksheets("COPY THIS").Visible = True
Sheets("COPY THIS").Select
ActiveSheet.Cells.Select
Selection.Copy
Sheets("FINAL").Select
Sheets("FINAL").Range("A1").PasteSpecial Paste:=xlValues
Worksheets("COPY THIS").Visible = False
Application.CutCopyMode = False
' Now we will fill up all the values in columns A/B/C (THIS IS THE PART THAT ISN'T WORKING):
Sheets("FINAL").Select
Lastrow = Range("A65000").End(xlUp).Row
For i = Lastrow To 2 Step -1
If Not IsError(Range("A" & i)) Then
RecordA = Range("A" & i)
RecordB = Range("B" & i)
RecordC = Range("C" & i)
Else
Range("A" & i) = RecordA
Range("B" & i) = RecordB
Range("C" & i) = RecordC
End If
Next i
End Sub
I had that last part on the separate button and it worked just fine. But now it just doesn't do anything. Like I said, I don't get an error message. It just doesn't do what it's supposed to do (fill UP columns A/B/C). Thanks for any help you can provide.