gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,341
- Office Version
- 365
- Platform
- Windows
I have a table that I want to make sure the user did not add any columns to and that they only entered one row of data before I run the rest of my code. I need a message box that states if there are added columns or more then one row of data. And then exit the code.
The table is on a sheet named sheet("Step 1")
The table name is "Table1"
Thank You!!
The table is on a sheet named sheet("Step 1")
The table name is "Table1"
Code:
Option Explicit
Sub PopoulateProducts()
Dim lr As Long
Sheets("Products").Select
'Clear existing data if any
lr = Sheets("Products").Cells(Rows.Count, "A").End(xlUp).Row
If lr > 2 Then Sheets("Parts").Range("A3:D" & lr).ClearContents
'Move data from Step 1 to Products tab
Products.Range("A3").Value = Sheets("Step 1").Range("C7")
Products.Range("B3").Value = Sheets("Step 1").Range("D7")
Products.Range("C3").Value = Sheets("Step 1").Range("C7").Value & " " & Sheets("Step 1").Range("D7")
'End If
Sheets("Step 2").Activate
End Sub
Thank You!!