Need Help on VBA

golfduke

New Member
Joined
Feb 17, 2009
Messages
3
I am using excel 2000.
How do I Change the Format of Bold and an Alignment Horizontal to "Left indent" and the Indent to the value of another field?
This needs to happen for a range of rows. It can be variable at any given time.

So if Field b2=2 I want to set field A2 to Bold and Horizontal of Left Align and Indent of 1-B2 (so indent of 1).
Conditional formatting does not do it.
I am not familiar with VB enough to do this by myself.

Thanks

Steve
 
Hi Steve
I'm no expert in VBA either.
But this will do the trick.
However, I'm sure there will be others that will provide far better results.

Code:
Sub Macro1()
    If Range("A2").Value = 2 Then
    Range("A1").Select
    With Selection
        .HorizontalAlignment = xlLeft
        .AddIndent = False
        .IndentLevel = 1
    End With
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Bold"
        .Size = 10
    End With
End If
End Sub

Regards
Michael M
 
Upvote 0

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