#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Macros

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros in Personal.xls that would create two toolbars and buttonswith assigned macros Brian Day Excel Programming 1 March 29th 07 11:20 PM
choose default macros Not Enabled / Macros Enable Setting BEEJAY Excel Programming 2 June 30th 06 01:07 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
convert lotus 123w macros to excel macros rpiescik[_2_] Excel Programming 1 September 19th 04 12:41 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"