NEW TO VBA - NEED HELP CODING

Yoyosassy

New Member
Joined
Apr 11, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I created a macro and it work great on the file that I created it with. I need to be able to run this same macro on new spreadsheets that I download where the number of rows varies as well as the file name/tab name.

I am getting this error, but I suspect I will have more errors because of my lack of understanding the correct coding. The error occurs at the highlighted line.

I am basically trying to get it to sort by selecting Row 2 to all rows with data and then the items following I was sorting by Column C, B & E to which I also need it to know that the number of rows will vary.

I appreciate any help anyone can offer. Please forgive me as I am learning and am a novice user of VBA.

1681197264365.png


1681197400567.png
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Remove the 2 in the line giving the error and change Rows to Range (also when posting code please paste it directly in the thread not as an image so it can be copied, preferably in code tags).

The line also needs to be below the line defining the lastrow if you don't have another line above it defining the lastrow.

Although you don't seem to be doing anything with the line giving the error?
 
Upvote 0

Forum statistics

Threads
1,213,491
Messages
6,113,963
Members
448,536
Latest member
CantExcel123

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