View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
a a is offline
external usenet poster
 
Posts: 51
Default Resize and a question

If anybody could help with this - I would so much appreciate it.

I import a csv file and the negative numbers have a trailing negative
sign. My process below will take the trailing negative sign and put it
where it should be - in front.

My problem is that the code below is only for the 10th column. I know
that I could write code that would repeat for the columns starting with
column 4 but it seems to me that a resize should work. Apparently I
have completely lost my capacity to use "resize".

Also - I think that I use the "myRange.Rows(i).cells.activate" and then
the replace part of the code must be causing me problems.

Please - I just don't get it.

As always - any help would be much appreciated.

Thanks in advance!
Anita


Dim dateInRow As Boolean
Application.ScreenUpdating = False
With ActiveSheet
Set myRange = .Cells(2, 10).Resize(.Cells(Rows.Count, _
1).End(xlUp).Row, 10)
For i = 1 To myRange.Rows.Count

For Each cell In myRange.Rows(i).Cells
If Right(Trim(cell.Value), 1) = "-" Then
myRange.Rows(i).Cells.Activate
ActiveCell.Replace What:="-", Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Cells.Find(What:="-", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
myRange.Rows(i).Cells.Activate
ActiveCell.Value = "-" & ActiveCell.Value
Exit For
End If
Next cell
If Not dateInRow Then myRange.Rows(i).Hidden = False
Next i
End With
Application.ScreenUpdating = True
End Sub