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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Status
Not open for further replies.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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