Slight Amendment To Recorded Macro

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
I have the recorded macro below that adjusts columns to where I want them. Problem is when I am half way down the sheet and run it it jumps to the top. What needs adding to it remains where I am once run? Thanks

Code:
Sub AdjustColumns()
'
' Macro1 Macro
'

'
    Columns("B:B").ColumnWidth = 1.29
    Columns("C:C").ColumnWidth = 13
    Columns("D:D").ColumnWidth = 1.43
    Columns("E:E").ColumnWidth = 7.29
    Columns("G:G").ColumnWidth = 6
    Columns("H:H").ColumnWidth = 8.71
    Columns("I:I").ColumnWidth = 6.86
    Columns("J:J").ColumnWidth = 5.86
    Columns("K:K").ColumnWidth = 0.08
    Columns("M:M").ColumnWidth = 0.5
    Columns("R:R").ColumnWidth = 0.75
    Columns("S:S").ColumnWidth = 3.57
    Columns("T:AA").Select
    Selection.ColumnWidth = 0.67
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 7
    End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try replacing your 2 lines:-

VBA Code:
    Columns("T:AA").Select
    Selection.ColumnWidth = 0.67

with this:-

VBA Code:
Columns("T:AA").ColumnWidth = 0.67

I also don't understand what you are trying to achieve with the ScrollColumn lines. I don't think you need them.
 
Upvote 0
Try replacing your 2 lines:-

VBA Code:
    Columns("T:AA").Select
    Selection.ColumnWidth = 0.67

with this:-

VBA Code:
Columns("T:AA").ColumnWidth = 0.67

I also don't understand what you are trying to achieve with the ScrollColumn lines. I don't think you need them.
That was just in the code after the record.
 
Upvote 0
I the selected cell, should now stay unchanged, if you started in A1 it should end in A1. If you want to finish somewhere else send a screenshot of how you want to it to look when it finishes.
 
Upvote 0
I the selected cell, should now stay unchanged, if you started in A1 it should end in A1. If you want to finish somewhere else send a screenshot of how you want to it to look when it finishes.
Well if I am in cell H10000 for example and I run the code I want it to stay in H10000 and not jump back to the top.
 
Upvote 0
That is exactly what it does after the modification.
If its not doing that then the quickest way of resolving it is if you just replace your code in full with the below.

VBA Code:
Sub AdjustColumns()
' Macro1 Macro
    Columns("B:B").ColumnWidth = 1.29
    Columns("C:C").ColumnWidth = 13
    Columns("D:D").ColumnWidth = 1.43
    Columns("E:E").ColumnWidth = 7.29
    Columns("G:G").ColumnWidth = 6
    Columns("H:H").ColumnWidth = 8.71
    Columns("I:I").ColumnWidth = 6.86
    Columns("J:J").ColumnWidth = 5.86
    Columns("K:K").ColumnWidth = 0.08
    Columns("M:M").ColumnWidth = 0.5
    Columns("R:R").ColumnWidth = 0.75
    Columns("S:S").ColumnWidth = 3.57
    Columns("T:AA").ColumnWidth = 0.67
End Sub
 
Upvote 0
Solution
That is exactly what it does after the modification.
If its not doing that then the quickest way of resolving it is if you just replace your code in full with the below.

VBA Code:
Sub AdjustColumns()
' Macro1 Macro
    Columns("B:B").ColumnWidth = 1.29
    Columns("C:C").ColumnWidth = 13
    Columns("D:D").ColumnWidth = 1.43
    Columns("E:E").ColumnWidth = 7.29
    Columns("G:G").ColumnWidth = 6
    Columns("H:H").ColumnWidth = 8.71
    Columns("I:I").ColumnWidth = 6.86
    Columns("J:J").ColumnWidth = 5.86
    Columns("K:K").ColumnWidth = 0.08
    Columns("M:M").ColumnWidth = 0.5
    Columns("R:R").ColumnWidth = 0.75
    Columns("S:S").ColumnWidth = 3.57
    Columns("T:AA").ColumnWidth = 0.67
End Sub
That's better, thank you.
 
Upvote 0
If you don't mind could you please mark my post with the vba code that you ended up using as the solution.
It helps other volunteers focus on the questions that still need help.
 
Upvote 0

Forum statistics

Threads
1,215,691
Messages
6,126,220
Members
449,303
Latest member
grantrob

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