Excel VBA Sort when Inputting Data, Updated in All Other Sheet?

panpan

New Member
Joined
Dec 18, 2020
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
Hello! I am new into VBA Excel.

I wanna create a database for each month, with 1 'Main Sheet' for the list of name, and the list on 'Main Sheet' will sort automatically as a row when I entered a data along with the update of the other sheet.

I found this code, and it's only updated/sorting in the sheet entered (let's we said the 'Main Sheet'). Is that possible if the entered data and sorting updated automatically in all other sheet?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Column = 1 Then
    
        Dim lastRow As Long
        lastRow = Cells(Rows.Count, 1).End(xlUp).Row
        Range("A2:BN2" & lastRow).Sort key1:=Range("A2:A" & lastRow), order1:=xlAscending, Header:=xlNo
    
    End If
End Sub

I tried referencing/paste link the name for each month (start from A2), but I have no idea to keep the column beside A2 (B2, C2, etc) sticking with the A2 as a full row.

Thanks!
 

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

Forum statistics

Threads
1,215,510
Messages
6,125,222
Members
449,216
Latest member
biglake87

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