find last column and paste data

hkbhansali

Board Regular
Joined
Oct 26, 2013
Messages
51
Basically I have an excel spreadsheet which can be updated daily. What I need is a macro that finds the last 'used' column (Headers are in row 1),

copy data from cell "D2" and paste it in to column E2 to H2 (may be more/less column) based on headers in row 1.

hope someone can help!!

Thanks in advance
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub hkbhansali()
   Range("D2").Copy Range("E2").Resize(, Cells(1, Columns.Count).End(xlToLeft).Column - 4)
End Sub
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,130,323
Messages
5,641,531
Members
417,215
Latest member
Diaryman

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