duffers123
New Member
- Joined
- Dec 20, 2013
- Messages
- 6
Hello there,
This is my 1st time trying to code in VBA. I have a table (with formatting) with 8 columns on sheet 1 of my workbook in Excel 2007. I have created a button that when clicked it adds 37 rows to my table (just enough to add another page for printing). Below is my code
Is it possible for the new cells to have the same formatting as the rest of the table?
Another issue I am having is that I want sheet 2 to display the same table just with three columns removed. I cannot get the table in sheet 2 to add new rows after clicking the button on sheet 1.
Any help would be much appreciated... Thanks
This is my 1st time trying to code in VBA. I have a table (with formatting) with 8 columns on sheet 1 of my workbook in Excel 2007. I have created a button that when clicked it adds 37 rows to my table (just enough to add another page for printing). Below is my code
Code:
Sub Button1_Click()If Not IsEmpty(ActiveCell.Value) Then
For i = 1 To 37
Selection.EntireRow.Insert
Range("B" & Selection.Row).Formula = "=R[-1]C+1"
Range("B" & Selection.Row + 1).Formula = "=R[-1]C+1"
Next
Else
MsgBox "Please place the cursor within the table"
End If
End Sub
Is it possible for the new cells to have the same formatting as the rest of the table?
Another issue I am having is that I want sheet 2 to display the same table just with three columns removed. I cannot get the table in sheet 2 to add new rows after clicking the button on sheet 1.
Any help would be much appreciated... Thanks