Macro Code not recording properly

mcomey

New Member
Joined
Sep 10, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi
I'm trying to record a simple macro using the macro record feature. No matter what I select to record it doesn't work.
This is the code it generated when I removed the background colour and unmerged cells A2: E2

When I run it it says Compile Error, Invalid or unqualified reference and hightlights .SortMethod

Sub Macro2()
'
' Macro2 Macro
'

'
Range("A2:E2").Select
With .SortMethod
.WhichAddress = xlNone
.PercentMin = 0
.Placement = 0
End With
With
.Orientation = xlGeneral
. = xlBottom
. = FALSE
. = 0
.MatchCase = False
.SortMethod = 0
. = FALSE
. = xlContext
.SetRange = True
End With
.
Range("A2").Select
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
That code is complete garbage. I'd suggest reinstalling Office.
 
Upvote 0
Rory, thanks for the quick reply. I actually did reinstall before posting on this forum. I should have said that in the last post. I think I need to create a new windows profile.
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,313
Members
453,031
Latest member
Chris_1

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