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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,223,920
Messages
6,175,376
Members
452,638
Latest member
Oluwabukunmi

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