Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a list of numbered articles of which the first four digits represents
a unique customer number. I am trying to create a macro to select those first four digits, copy them and paste them in an adjacent cell. When I create a macro it seems that whenever it is executed, no matter what data is in the cell it is trying to extract data from, it always returns the data obtained when the macro was created. I have tried relative mode as well, same result. I have also tried incorporating clearing of the clipboard into the macro, to no avail. I don't know VBA, but I used to be fair at BASICA. Any suggestions? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
sounds like you may have done it on record and the data is hard coded into the code. post your macro. but as a thought, a formula might do better for you =left(A1,4) copy down as far as you need. Regards FSt1 "Rob Rudan" wrote: I have a list of numbered articles of which the first four digits represents a unique customer number. I am trying to create a macro to select those first four digits, copy them and paste them in an adjacent cell. When I create a macro it seems that whenever it is executed, no matter what data is in the cell it is trying to extract data from, it always returns the data obtained when the macro was created. I have tried relative mode as well, same result. I have also tried incorporating clearing of the clipboard into the macro, to no avail. I don't know VBA, but I used to be fair at BASICA. Any suggestions? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is the code for the macro. The formula solution did work by the way.
Thanks very much for your help! Sub cusnum() ' ' cusnum Macro ' Macro recorded 11/6/2008 by rrudan ' ' Keyboard Shortcut: Ctrl+q ' Range("B2").Select ActiveSheet.Paste Range("B3").Select End Sub "FSt1" wrote: hi sounds like you may have done it on record and the data is hard coded into the code. post your macro. but as a thought, a formula might do better for you =left(A1,4) copy down as far as you need. Regards FSt1 "Rob Rudan" wrote: I have a list of numbered articles of which the first four digits represents a unique customer number. I am trying to create a macro to select those first four digits, copy them and paste them in an adjacent cell. When I create a macro it seems that whenever it is executed, no matter what data is in the cell it is trying to extract data from, it always returns the data obtained when the macro was created. I have tried relative mode as well, same result. I have also tried incorporating clearing of the clipboard into the macro, to no avail. I don't know VBA, but I used to be fair at BASICA. Any suggestions? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
you code does paste someting but doesn't give any indication as to what. if the formula worked , i would stick with that. sometimes the easy way is the easiest way. Regards FSt1 "Rob Rudan" wrote: Here is the code for the macro. The formula solution did work by the way. Thanks very much for your help! Sub cusnum() ' ' cusnum Macro ' Macro recorded 11/6/2008 by rrudan ' ' Keyboard Shortcut: Ctrl+q ' Range("B2").Select ActiveSheet.Paste Range("B3").Select End Sub "FSt1" wrote: hi sounds like you may have done it on record and the data is hard coded into the code. post your macro. but as a thought, a formula might do better for you =left(A1,4) copy down as far as you need. Regards FSt1 "Rob Rudan" wrote: I have a list of numbered articles of which the first four digits represents a unique customer number. I am trying to create a macro to select those first four digits, copy them and paste them in an adjacent cell. When I create a macro it seems that whenever it is executed, no matter what data is in the cell it is trying to extract data from, it always returns the data obtained when the macro was created. I have tried relative mode as well, same result. I have also tried incorporating clearing of the clipboard into the macro, to no avail. I don't know VBA, but I used to be fair at BASICA. Any suggestions? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
but here a macro anyway..... Sub Robsfirstfour() Dim r As Range Dim lr As Long lr = Cells(Rows.Count, "A").End(xlUp).Row Set r = Range("A2:A" & lr) For Each cell In r cell.Offset(0, 1).Value = Left(cell, 4) Next cell MsgBox "Done" End Sub regards FSt1 "FSt1" wrote: hi you code does paste someting but doesn't give any indication as to what. if the formula worked , i would stick with that. sometimes the easy way is the easiest way. Regards FSt1 "Rob Rudan" wrote: Here is the code for the macro. The formula solution did work by the way. Thanks very much for your help! Sub cusnum() ' ' cusnum Macro ' Macro recorded 11/6/2008 by rrudan ' ' Keyboard Shortcut: Ctrl+q ' Range("B2").Select ActiveSheet.Paste Range("B3").Select End Sub "FSt1" wrote: hi sounds like you may have done it on record and the data is hard coded into the code. post your macro. but as a thought, a formula might do better for you =left(A1,4) copy down as far as you need. Regards FSt1 "Rob Rudan" wrote: I have a list of numbered articles of which the first four digits represents a unique customer number. I am trying to create a macro to select those first four digits, copy them and paste them in an adjacent cell. When I create a macro it seems that whenever it is executed, no matter what data is in the cell it is trying to extract data from, it always returns the data obtained when the macro was created. I have tried relative mode as well, same result. I have also tried incorporating clearing of the clipboard into the macro, to no avail. I don't know VBA, but I used to be fair at BASICA. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macros in Personal.xls that would create two toolbars and buttonswith assigned macros | Excel Programming | |||
choose default macros Not Enabled / Macros Enable Setting | Excel Programming | |||
weird saving of a document with macros resulting with macros being transfered to the copy | Excel Programming | |||
convert lotus 123w macros to excel macros | Excel Programming | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming |