Two or more VBA in one worksheet

Jennifer Van

New Member
Joined
Apr 22, 2022
Messages
41
Office Version
  1. 2016
Platform
  1. Windows
I already have a VBA which copies a line from worksheet Loan Request Return to another worksheet called WaitList if cell Q says yes.

What I need now is if another cell "AB" says Yes, to copy the cell to another worksheet "Repairs Remove"

And if possible, columns K,L,M data (if data is in there) only be copied to a sheet called Equipment Library and not only to an empty cell, it goes to the cell which holds the same UID (UniqueID) which then shows that the equipment is on loan etc?

Thank you, I know this is a lot to ask
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
We would need a lot more specific details here
Like you said:
"What I need now is if another cell "AB" says Yes, to copy the cell to another worksheet "Repairs Remove"

There is no cell "AB". We have Ranges like "AB45" Or "AB36"
And you said to another Sheet Named "Repairs Removed" But did not say where on the sheet to copy it to.
 
Upvote 0
We would need a lot more specific details here
Like you said:
"What I need now is if another cell "AB" says Yes, to copy the cell to another worksheet "Repairs Remove"

There is no cell "AB". We have Ranges like "AB45" Or "AB36"
And you said to another Sheet Named "Repairs Removed" But did not say where on the sheet to copy it to.
Sorry
AB6 has question asking if equipment needs repairs - dropdown yes or no
If the answer is yes, then I want the line (or only certain columns if possible), copied to a worksheet named "Repairs Remove" and for the information to be copied at the next vacant cell on the sheet as it would already have previous information on it.

Does this make sense now? (sorry)
Jen
 
Upvote 0
Do you want the script to be activated when you enter "yes" in the range("AB6") or when you press a button.
And if not the entire row to be copied what part of the row do you want copied?
And where exactly do we paste it?
 
Upvote 0
Do you want the script to be activated when you enter "yes" in the range("AB6") or when you press a button.
And if not the entire row to be copied what part of the row do you want copied?
And where exactly do we paste it?
When I answer yes is fine
Copy columns L,M,N over to worksheet Repairs Remove - next available row on that sheet
 
Upvote 0
You said:
next available row on that sheet

So if we only copy cells in columns L,M,N

Do be post these three cells in columns A,B,C or if not exactly where?
first empty cell in column A?
 
Upvote 0
Try this:

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
The script will run when you enter "Yes" In Range ("AB6")
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  4/23/2022  3:24:28 AM  EDT
If Target.Address = "$AB$6" Then
Dim r As Long
r = Target.Row
Dim Lastrow As Long
Lastrow = Sheets("Repairs Remove").Cells(Rows.Count, "L").End(xlUp).Row + 1

If Target.Value = "Yes" Then
    Cells(r, "L").Resize(, 3).Copy Sheets("Repairs Remove").Cells(Lastrow, "L")
End If

End If

End Sub
 
Upvote 0
Try this:

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
The script will run when you enter "Yes" In Range ("AB6")
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  4/23/2022  3:24:28 AM  EDT
If Target.Address = "$AB$6" Then
Dim r As Long
r = Target.Row
Dim Lastrow As Long
Lastrow = Sheets("Repairs Remove").Cells(Rows.Count, "L").End(xlUp).Row + 1

If Target.Value = "Yes" Then
    Cells(r, "L").Resize(, 3).Copy Sheets("Repairs Remove").Cells(Lastrow, "L")
End If

End If

End Sub
Hi
It came back with Ambiguous name detected - would this because I already have another VBA above?
 

Attachments

  • Image 1.JPG
    Image 1.JPG
    92.1 KB · Views: 6
Upvote 0
Yes that is the problem. Show me the code you already have in your sheet.
Post the code here do not just show a image of it. And I will fix it all.
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,222
Members
453,024
Latest member
Wingit77

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