Macros

  • Thread starter Thread starter Rob Rudan
  • Start date Start date
R

Rob Rudan

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?
 
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
 
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top