View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
SeanC UK[_2_] SeanC UK[_2_] is offline
external usenet poster
 
Posts: 63
Default Right() error changing columns in macro

Hi,

the reference:

Range(Cells(1, 2), Cells(.UsedRange.Rows.Count, 2))

can be seen as:

Range(TopLeftCell,BottomRightCell)

where I have defined the top left and bottom right cells using:

Cells(Row Number, Column Number)

So to start from Row 3 Column B to the last cell in column B change the code
to:

Range(Cells(3, 2), Cells(.UsedRange.Rows.Count, 2))

The code you used - Right(Text,6) will replace all the cells with just the
last 6 characters in each cell.

I hope this helps,

Sean.



--
(please remember to click yes if replies you receive are helpful to you)


"S Himmelrich" wrote:

We got closer with this one, but I'm getting some rows replacing with
less characters. Basically I should be searching B3 to last cell in
column be and replacing with last six characters.....I'm not that good
with VB so I'm not clear on what I'd change in this statement "For
Each rngCells In Range(Cells(1, 2), Cells(.UsedRange.Rows.Count, 2))"




On Dec 12, 11:41 am, SeanC UK
wrote:
Hi S,

Can try:

Dim rngCells As Range
With ActiveSheet
For Each rngCells In Range(Cells(1, 2), Cells(.UsedRange.Rows.Count, 2))
rngCells.Value = Right(rngCells.Value, 6)
Next
End With

Sean.

--
(please remember to click yes if replies you receive are helpful to you)



"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)- Hide quoted text -


- Show quoted text -