VBA Macro to find a value in another worksheet, delete that row, move that row to another worksheet.

michaelm0162

New Member
Joined
Oct 21, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I am the definition of a VBA beginner. I only google codes and try to manipulate them to do what i need but i could not find to do this exactly to manipulate.
I have a form where its a check in/check out for our company for parts.

The first If statement works perfectly
1603299524700.png

on the "FORM" tab i have this off the side
1603299560351.png

When R3 = anything other than 1 (hence the else)
I want it to look up the "Tool Number", "M5" in "Form", in the "ToolsInToolRoom" sheet and delete that row (IF IT IS NOT ON THE LIST THEN CONTINUE)
Then i want it to take "L5:O5" and paste it into "CheckOutHistory"

I have the following code based on a button:

Sub Button10_Click()
If Worksheets("Form").Range("R3").Value = 1 Then
Sheets("Form").Range("L5:O5").Copy
Sheets("ToolsInToolRoom").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
Sheets("Form").Range("D5:D8").ClearContents
Sheets("Form").Range("C16:I21").ClearContents
MsgBox "Check in complete."

Else
Sheets("Form").Range("L5:O5").Copy
Sheets("CheckOutHistory").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
*****NEED HELP HERE*****
Sheets("Form").Range("D5:D8").ClearContents
Sheets("Form").Range("C16:I21").ClearContents
MsgBox "Check out complete."
End If
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,566
Messages
6,125,596
Members
449,238
Latest member
wcbyers

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