Macro is getting ruined

Status
Not open for further replies.

M3L333

New Member
Joined
Jul 31, 2018
Messages
15
I have been re-working this macro for quite some time. First started by pasting info to new sheet on last row, then successfully changed the macro to insert a new row on top and paste to new sheet. Then noticed that the sheet i was pasting to only was moving the row down in certain columns. I want to entire row to move down....now the macro doesn't seem to be pasting to a new sheet at all. I need help PLEASE!! Make my macro work again.


Private Sub CommandButton1_Click()


Dim lr As Long
Dim r As Long
Dim nr As Long


Application.ScreenUpdating = False


'Find lr column P with data on Bed Registry
lr = Sheets("Bed Registry").Cells(Rows.Count, "P").End(xlUp).Row


'Find lcol - Last Column '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'lcol = Sheets("Bed Registry").ActiveSheet.Cells(1, Application.Columns.Count).End(xlToRight).Column


'Loop through all rows on Bed Registry and check column P for closed
For r = 2 To lr
If Sheets("Bed Registry").Cells(r, "P") = "CLOSED" Then
'Sheets("Discharges").Activate
'Insert r at r2 on "Discharges" Sheet
'Rows("2:2").Insert Shift:=xlDown,
'CopyOrigin:=xlFormatFromLeftOrAbove
'Copy columns B-P to "Discharges" on row 2
'Sheets("Bed Registry").Range(Cells(r, "B"), Cells(r, "P")).Copy Sheets("Discharges").Range (Cells(2, "B"), (Cells r, "P"))
'Clear columns B-P on Bed Registry
Sheets("Bed Registry").Range(Cells(r, "B"), Cells(r, "P")).ClearContents
End If
Next r


End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Status
Not open for further replies.

Forum statistics

Threads
1,216,471
Messages
6,130,822
Members
449,595
Latest member
jhester2010

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top