Macro for copying value to specific cells

Ivica1987

New Member
Joined
Sep 20, 2016
Messages
14
Hello

Since I don't use much Excel Macro I will need help with a VBA Macro for Excel. What I need is to copy a specific value from the 5th row (the Main Value) depending which month it is (cell K1). As an example: if the month is equal to number 9 then it will copy the value from the cell for September (cell AD5: 125068) to the column D for each of the three employees (the orange fields).

I can maybe solve this with normal formulas and with the VBA function for recording, but it could happen that next month the number of employees is different and so the recorded macro wouldn't work. Also, I will need something that works on multiple sheets since every table in every sheet has the same layout.

Here is an example.

Thanks in advance and best regards
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Same value you want to paste in column D . 125068 in three cells ??

[TABLE="width: 500"]
<tbody>[TR]
[TD]Max Muster[/TD]
[TD]125068[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Peter Peterson[/TD]
[TD]125068[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Christian Christianson[/TD]
[TD]125068[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0
put this formula into cell d7 and just confirm it with CTRL+SHIFT+ENTER then drag it to cell d9

=INDEX($F$5:$AO$5,MATCH($K$1,MONTH($F$4:$AO$4),0))

hope that helps
 
Last edited:
Upvote 0
<embed width="440" height="420" type="application/x-shockwave-flash" src="http://v9.tinypic.com/player.swf?file=n2g3go&s=9">


CTRL+SHIFT+ENTER

Formulla = =INDEX($F$5:$AO$5,MATCH($K$1,MONTH($F$4:$AO$4),0))
 
Upvote 0
Sadly it didn't help much. Excel is showing me an error (Value error). I tried it on english and german versions of Excel.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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