nareshkumarv
New Member
- Joined
- Nov 23, 2016
- Messages
- 2
I have the button in sheet2, my requirement is when I press the button in sheet2, I have to merge Cells A1 to A3 in sheet1.
here is my code
Private Sub CommandButton1_Click()
Sheets("Sheet1").Select
Range("A3:C3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub
but it is giving following error code
"Run time error '1004'
Select method of Range class failed
here is my code
Private Sub CommandButton1_Click()
Sheets("Sheet1").Select
Range("A3:C3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub
but it is giving following error code
"Run time error '1004'
Select method of Range class failed