View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
S Himmelrich S Himmelrich is offline
external usenet poster
 
Posts: 76
Default Right() error changing columns in macro

I'm getting invalid command error on line:
set myrng = .range("B1", .cells(.rows.count,"B").end(xlup))



On Dec 12, 11:34 am, Dave Peterson wrote:
You need to loop through the cells if you want to use right().

dim myCell as range
dim myRng as range
with worksheets("somesheetnamehere")

end with
for each mycell in myrng.cells
mycell.value = right(mycell.value,6)
next mycell

=========
You may want to record a macro when you:
select column B
data|Text to columns|Fixed width
and draw a line after the 6th character
and do not import the field(s) to the right of that line

S Himmelrich wrote:

I get an error when I run this in a macro...what can I do.


' Convert account column
Columns("B:B").Select
Selection.Value = Right(Range("B:B").Value, 6)


--

Dave Peterson