Help updating this code to sort current region by Column A then Column G?

Coyotex3

Active Member
Joined
Dec 12, 2021
Messages
496
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a code that finds a specific word and delete 3 rows above it(therefore removing blank cells between two similar ranges.) I would like to be able to select the current region and resort. Here is what I have come up with so far. This removes my columns for me but I can't figure out the rest.
VBA Code:
Sub Delete_Rows()
    Range("A" & Rows.Count).End(xlUp).Select
    Const WordToLook = "NYC"
    Dim RowWord As Long
    RowWord = Columns(4).Find(WordToLook, LookAt:=xlWhole).Row
    Rows(RowWord - 3 & ":" & RowWord - 1).Delete
End Sub
 
This will sort the last two blocks.
VBA Code:
Sub coyotex()
   Dim UsdRws As Long
 
   UsdRws = Range("A" & Rows.Count).End(xlUp).Row
   With Range("A:A").SpecialCells(xlConstants)
      With Range(.Areas(.Areas.Count - 1), Range("A" & UsdRws)).Resize(, 8)
         .Sort .Range("A1"), xlAscending, .Range("G1"), , xlAscending, Header:=xlNo
      End With
   End With
End Sub
An absolute gem yet again!! Once again, Fluff, thank you for everything and sorry about not explaining things as clearly as I had hoped. Truly helping me and my team out!
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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