Recorded code - change inset default setting

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,644
Office Version
  1. 365
Platform
  1. Windows
Code from the macro recorder is inset like this :
Code:
Sub Macro1()
    Range("A2").Select
End Sub

Is it possible to have no inset when using the recorder? Like this :
Code:
Sub Macro1()
Range("A1").Select
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I am not sure if it is possible. But perhaps this short keystroke combination might be good enough - Ctrl + A to highlight all the code, followed by Ctrl + Shift + Tab to shift everything to the left.
 
Upvote 0
I am not sure if it is possible. But perhaps this short keystroke combination might be good enough - Ctrl + A to highlight all the code, followed by Ctrl + Shift + Tab to shift everything to the left.

That's exactly the sort of thing I want to avoid having to do.
 
Upvote 0
Why would you not want the code to be indented?

Using indentation in code makes it more readable and easier to follow/debug.
 
Upvote 0
Why would you not want the code to be indented?

Using indentation in code makes it more readable and easier to follow/debug.

I don't want the code indented between Sub and End Sub - like in the example I provided.
I do want indents within the code.

I don't want this :
Code:
Sub Macro1()
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1:A6"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("A1:A6")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

I want this :
Code:
Sub Macro1()
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1:A6"), _
    SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
    .SetRange Range("A1:A6")
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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