VBA Excel copy cell value, find value in other worksheet, then paste row where the found cell value is

andycreber

Board Regular
Joined
May 20, 2010
Messages
74
Office Version
  1. 2016
Hi, I'm new to VBA, i need help to copy cell value, find value in other worksheet, then paste row where the found cell value is. I am using a workbook as a template so each user can use it.

I have a worksheet called "Survey" I want a vba code to copy the cell value in cell "J5"

Go to worksheet "Raw_Data" find the value of the cell J5 from the sheet "Survey" in column "AW" on the Raw_Data tab then paste special that particular row and then save the workbook as an xlsx and with the template clear the contents in cell J5 on the "Survey" sheet.

This is what I have so far but I am stuck finding and pasting the data.

Sheets("Survey").Select

On Error Resume Next
ThisWorkbook.Sheets(Worksheets("Survey").Range("J5").Value).Activate



Selection.Copy
Sheets("Raw_Data").Select
Columns("AW:AW").Select



Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False



Workbooks("Voluntary Assessment Tool Master.xlsx").Save

Application.DisplayAlerts = False

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I could not understand what you were trying to do here.
1) You have Sheets("Survey") and Sheets("Raw_Data")
2) You want to find value in Sheets("Survey").Range("J5") in Sheets("Raw_Data") in column "AW".
3) Once found, you want to to PasteSpecial that particular row.

The particular row is the row in which sheets? Raw_Data sheet? Then you want to paste with what? The Range("J5") value in Survey sheet is the same as the value found in Sheet("Raw_Data"). So, what you wanted to paste and where?
 
Upvote 0
I could not understand what you were trying to do here.
1) You have Sheets("Survey") and Sheets("Raw_Data")
2) You want to find value in Sheets("Survey").Range("J5") in Sheets("Raw_Data") in column "AW".
3) Once found, you want to to PasteSpecial that particular row.

The particular row is the row in which sheets? Raw_Data sheet? Then you want to paste with what? The Range("J5") value in Survey sheet is the same as the value found in Sheet("Raw_Data"). So, what you wanted to paste and where?
I managed to fix it, thanks for asking
 
Upvote 0

Forum statistics

Threads
1,212,928
Messages
6,110,734
Members
448,294
Latest member
jmjmjmjmjmjm

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