![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Los Angeles, CA
Posts: 752
|
I am not a pro at macros, I am learning as I go. My problem is that I want the minus sign to move from the right to the left, and that works fine. The problem is...the range changes in reference to the number of rows column A occupies.
The minus sign I want to move are in columns L through N and Q through W Can someone please help, Thanks ColumnARange = Intersect(ActiveSheet.UsedRange, Columns("A")).Address Range("K2:m2").Select On Error Resume Next Dim cel As Range Dim myVar As Range Set myVar = Selection For Each cel In myVar If Right((Trim(cel)), 1) = "-" Then cel.Value = cel.Value * 1 End If |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: London, UK
Posts: 167
|
try this...
Sub test() rowx = 2 For colx = 12 To 14 ' L through to Q valx = Cells(rowx, colx).Value If Right(valx, 1) = "-" Then Cells(rowx, colx).Value = "-" & Left(valx, Len(valx) - 1) End If Next For colx = 17 To 23 ' Q through to W valx = Cells(rowx, colx).Value If Right(valx, 1) = "-" Then Cells(rowx, colx).Value = "-" & Left(valx, Len(valx) - 1) End If Next End Sub |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Los Angeles, CA
Posts: 752
|
I tried it and it did not work. Any ideas??? Thanks
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi Parra. how about this
Sub test2() Dim rng As Range For Each rng In Range("Q:W,L:N").SpecialCells(2) With rng If Right(.Value, 1) = "-" Then .Value = Val(.Value) * -1 End With Next End Sub [ This Message was edited by: Colo on 2002-04-04 22:33 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|