Macro to Indent with Left Condition...

storm925

Board Regular
Joined
Jan 20, 2010
Messages
226
Hello all, need some help again. I've written the following macro, however it does not produce any results.

Sub Indent_Row_8()
Dim LR As Long
LR = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
For i = LR To 3 Step -1
If ActiveSheet.Cells(i, "B") = Left("8", 1) _
Then Cells(i, "B").IndentLevel = 2
Next i
End Sub


What I would like to do is have a row indented if it starts out with the number 8. For example I have the following in column B:

kl54pl
asr98851
8001pos
olp223

and so I need the macro to indent "8001pos", since it started with the number 8. Most of the time the data will never be the same after the number 8, thus the reason for the LEFT command. Thanks again for looking at my post and any help would be great.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try changing

If ActiveSheet.Cells(i, "B") = Left("8", 1) _

to

If Left(ActiveSheet.Cells(i, "B"),1) = "8" _
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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