Hi all, I searched around a bit before posting and couldn't find my problem, sorry if this can be found elsewhere.
Problem 1: A command button within sheet 1 will not make changes in sheet 2.
Currently, my code looks like this, tied to a button in sheet 1:
[vb code]
Private Sub CommandButton1_Click()
'This inserts a new row
Sheets("sheet 1").Range("D9").Select
ActiveCell.EntireRow.Insert shift:=xlDown
'This formats the cells
Sheets("sheet 1").Range("C9:AG9").Select
Selection.Borders.Weight = xlThin
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
'This is where it stops working, but is the same code just a different sheet
Sheets("sheet 2").Range("D9").Select
ActiveCell.EntireRow.Insert shift:=xlDown
'This formats the cells
Sheets("sheet 2").Range("C9:AG9").Select
Selection.Borders.Weight = xlThin
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
End Sub
[\vb]
Problem 2: I also tried to write a macro that copies and pastes my formulas into a new row, but it's not working.
[vb code]
Dim y As Long
y = Application.InputBox("How many rows do you want to add?", "", Type:=1)
If y = 0 Then Exit Sub
With Sheets("sheet 3").[a65536].End(9).EntireRow.Copy.Resize(y).Insert
End With
Application.CutCopyMode = False
End Sub
[/vb]
Any help would be appreciated.
Bookmarks