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
65
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,881
Office Version
  1. 2016
Platform
  1. Windows
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?
 

andycreber

Board Regular
Joined
May 20, 2010
Messages
65
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
 

Forum statistics

Threads
1,148,194
Messages
5,745,276
Members
423,942
Latest member
excelhelp1423

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
Top