Macro to copy column from one sheet to another based on value in cell

afarlow

New Member
Joined
Sep 23, 2015
Messages
2
Good morning.

I have some basic VBA knowledge but am stumped with this one - have searched various forums but can't find the answer I need so am hoping one of you experts can point me in the right direction.

I have a spreadsheet with 3 sheets - Instructions, Variance and Data.

The Data sheet has a breakdown of information per week in each column.

1638181436458.png


I am trying to write a macro that will copy a column from the Data sheet and paste special it in column B on the Variance sheet if the value in Row 4 of the Data sheet is equal to the value in cell B4 of the Instruction Sheet.

The value in cell B4 of the Instruction sheet will change every week and I want the information from the data sheet to overwrite column B on the Variance sheet every week.

I have tried using an If Then statement

If Sheets("Data").Range("B4:ZZ4").Value = Sheets("Instructions").Range("C4") Then EntireColumn.Copy Sheets("Variance").Range("B1")

However, I get the RunTime error Type mismatch.

The data in the cells is a date and I have used the same format on both the Instructions and the Data sheet and can't work out why they don't match - have even copies the cell from the Data sheet to the Instructions sheet so I know they are identical.

Could someone please put me out of my misery!

Thank you
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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