macro to move column

congokin

Board Regular
Joined
Oct 31, 2010
Messages
74
i have data that changes dynamically in cola(a1-a10). i want to record each change of data in subsequent columns
step1
Excel Workbook
A
11
22
33
Sheet4
Excel 2007
step2
Excel Workbook
AB
141
272
393
Sheet4
Excel 2007
step3
Excel Workbook
ABC
14541
2672
33893
Sheet4
Excel 2007

the following macro does the job but copy cola 10 times instead of 1 per above example
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
forgot to put the code
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
    If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
        ' Application.EnableEvents = False
        Range("A1:A10").Copy Cells(1, LC + 1)
        ' Application.EnableEvents = True
    End If
End Sub
any help will be appreciated
 
Upvote 0
If the data is refreshed sequentially from A1 to A10 then perhaps

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
    If Not Intersect(Target, Range("A10")) Is Nothing Then
        ' Application.EnableEvents = False
        Range("A1:A10").Copy Cells(1, LC + 1)
        ' Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
thanks this works great

Will it be possble to extend this code so that when cell.value of last colum > cell.value of last colum -1 then color cell.value of last colum - 1 = red else no color
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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