macro to select and copy adjucent cells

kshitij_dch

Active Member
Joined
Apr 1, 2012
Messages
362
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
hi all i have some selected cells in Column F , i want a macro code which will select cells in column A adjucent to select cells in column F ... both select column cells than gets copied and gets pasted in column H and column I......
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try:
Code:
Sub MoveContent()
Dim cell As range
Application.ScreenUpdating = False
If ActiveCell.Column <> 6 Then
  MsgBox "Please select cells from Column F"
  Exit Sub
End If
For Each cell In Selection
    With cell
        .Offset(, -5).Copy
        .Offset(, 2).PasteSpecial xlPasteValues
        .Copy
        .Offset(, 3).PasteSpecial xlPasteValues
    End With
Next cell
With Application
    .CutCopyMode = False
    .ScreenUpdating = True
End With
End Sub
 
Upvote 0
hi thanks for the reply , error is comming in 4th line .copy.... sub function not defiled ???
 
Upvote 0
Works for me:

ABCDEFGHI
1D A DA
21 3 13
32 4 24
4B B BB

<COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 64px"><COL style="WIDTH: 35px"><COL style="WIDTH: 35px"><COL style="WIDTH: 35px"><COL style="WIDTH: 35px"><COL style="WIDTH: 64px"><COL style="WIDTH: 35px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY>
</TBODY>
 
Upvote 0

Forum statistics

Threads
1,203,535
Messages
6,055,966
Members
444,839
Latest member
laurajames

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