Range

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
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
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,292
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top