View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default 2 VBA enhancements

try this
Sub multiplybyone()
For col = 1 To Cells(Columns.Count).End(xlToLeft).Column
For i = 1 To Cells(Rows.Count, col).End(xlUp).Row
mc = Trim(Cells(i, 2))
If IsNumeric(mc) Then mc = mc * 1
Next i
Next col
End Sub

--
Don Guillett
SalesAid Software

"markx" wrote in message
...
Hello once again,

I have a very pretty macro now (thanks Duncan, thanks Kaak!)
-------------
Range("G2").Select
Do
If IsNumeric(Trim(ActiveCell.Value)) Then ActiveCell.Value =
Trim(ActiveCell.Value) * 1
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
-------------

At the present time, I would like however to add two small (general)
enhancements...
1) If I have to repeat the macro for 5 or 6 (or more) columns, I would
prefer not to copy/paste the code x times one after another, changing the
letter from G2 to K2, then M2 etc..., but to create the initial line in
VBA where I could specify a list (f. ex. =[G, K, M, O, P, X]) of columns
to treat with the code... (then modifying the "Range("G2").Select" line to
treat "G" like variable)...

2) Concerning the last line of the code = Loop Until
IsEmpty(ActiveCell.Offset(0, -1))
Is it possible to modify the code to tell:
Loop Until IsEmpty("cell in the same row that ActiveCell, but in the
column A")?


Many thanks in advance to all of you that could give me at least a hint
how to achieve this!!
Mark