melvinkoshy
New Member
- Joined
- Dec 13, 2017
- Messages
- 27
I have a DBFORMAT sheet where there are 6 types of DBs (Distribution boards) differentiated by headings in rows. There is an RADB sheet with a dropdown menu and “ADD” button. When I select the DB from dropdown menu and press ADD, the corresponding rows of item from the DBFORMAT is copied and pasted in the OUTPUT sheet.
I used the following code for copying which is working correctly
When I click ADD button, I wish to number the DBs automatically in the RADB sheet in the format DB1, DB2, DB3 and so on. The DB number should appear in Col. B of RADB sheet and immediate left to the title of the respective DB.
What is the code that has to be added to the above code for achieving the numbering to be used for the same? screenshot indicating the desired numbering is marked as red circles in the image attached.
Image file: http://s000.tinyupload.com/?file_id=02202116074460927041
Excel file: http://s000.tinyupload.com/?file_id=60065120454233364376
I used the following code for copying which is working correctly
Code:
Private Sub CommandButton1_Click()
If Worksheets("RADB").Range("E1") = "TPN" Then
Worksheets("DBFORMAT").Range("A2:M13").Copy
Worksheets("RADB").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
If Worksheets("RADB").Range("E1") = "VTPNRCBO" Then
Worksheets("DBFORMAT").Range("A15:M26").Copy
Worksheets("RADB").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
If Worksheets("RADB").Range("E1") = "VTPNMCCB" Then
Worksheets("DBFORMAT").Range("A28:M40").Copy
Worksheets("RADB").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
If Worksheets("RADB").Range("E1") = "PSDB" Then
Worksheets("DBFORMAT").Range("A42:M54").Copy
Worksheets("RADB").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
If Worksheets("RADB").Range("E1") = "FLEXY" Then
Worksheets("DBFORMAT").Range("A56:M67").Copy
Worksheets("RADB").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
If Worksheets("RADB").Range("E1") = "SPN" Then
Worksheets("DBFORMAT").Range("A69:M80").Copy
Worksheets("RADB").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial
End If
End Sub
When I click ADD button, I wish to number the DBs automatically in the RADB sheet in the format DB1, DB2, DB3 and so on. The DB number should appear in Col. B of RADB sheet and immediate left to the title of the respective DB.
What is the code that has to be added to the above code for achieving the numbering to be used for the same? screenshot indicating the desired numbering is marked as red circles in the image attached.
Image file: http://s000.tinyupload.com/?file_id=02202116074460927041
Excel file: http://s000.tinyupload.com/?file_id=60065120454233364376