ExcelAverage
New Member
- Joined
- Dec 10, 2012
- Messages
- 32
Hello guys,
I have this macro code in Sheet1 assigned to a button named Combination. I copied the whole sheet twice and moved to end. So they have the same data content and hopefully the macro in sheet1 will work as well in sheets2 and 3. But it's not. I just copied the code from VB codes Excel objects Sheet1 to Sheet2 and Sheet3. The cursor changed to a reading glass but it doesn't display any result. I am sure it's the worksheets(1).range part that needs to be edited but i am not sure if that is simply changing it to worksheets(2) or worksheets(3). I tried that also but no effect also. Please help.
This is the vb code i used in sheet 1 also from Mrexcel.com
-------------------------------------------------------------------------
Option Explicit
Public Sub ModelPricing_Template()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim e As Integer, f As Integer, g As Integer
Worksheets(1).Range("a15:IV65536").ClearContents
For a = 4 To 6
For b = 4 To 7
For c = 4 To 7
For d = 4 To 7
For e = 4 To 13
For f = 4 To 5
For g = 4 To 5
Worksheets(1).Range("A" & Range("A65536").End(xlUp).Row + 1) = Worksheets(1).Cells(a, 1)
Worksheets(1).Range("B" & Range("B65536").End(xlUp).Row + 1) = Worksheets(1).Cells(b, 2)
Worksheets(1).Range("C" & Range("C65536").End(xlUp).Row + 1) = Worksheets(1).Cells(c, 3)
Worksheets(1).Range("D" & Range("D65536").End(xlUp).Row + 1) = Worksheets(1).Cells(d, 4)
Worksheets(1).Range("E" & Range("E65536").End(xlUp).Row + 1) = Worksheets(1).Cells(e, 5)
Worksheets(1).Range("F" & Range("F65536").End(xlUp).Row + 1) = Worksheets(1).Cells(f, 6)
Worksheets(1).Range("G" & Range("G65536").End(xlUp).Row + 1) = Worksheets(1).Cells(g, 7)
Next g
Next f
Next e
Next d
Next c
Next b
Next a
End Sub
-------------------------------------------------------------------------
Thanks in advance again
I have this macro code in Sheet1 assigned to a button named Combination. I copied the whole sheet twice and moved to end. So they have the same data content and hopefully the macro in sheet1 will work as well in sheets2 and 3. But it's not. I just copied the code from VB codes Excel objects Sheet1 to Sheet2 and Sheet3. The cursor changed to a reading glass but it doesn't display any result. I am sure it's the worksheets(1).range part that needs to be edited but i am not sure if that is simply changing it to worksheets(2) or worksheets(3). I tried that also but no effect also. Please help.
This is the vb code i used in sheet 1 also from Mrexcel.com
-------------------------------------------------------------------------
Option Explicit
Public Sub ModelPricing_Template()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim e As Integer, f As Integer, g As Integer
Worksheets(1).Range("a15:IV65536").ClearContents
For a = 4 To 6
For b = 4 To 7
For c = 4 To 7
For d = 4 To 7
For e = 4 To 13
For f = 4 To 5
For g = 4 To 5
Worksheets(1).Range("A" & Range("A65536").End(xlUp).Row + 1) = Worksheets(1).Cells(a, 1)
Worksheets(1).Range("B" & Range("B65536").End(xlUp).Row + 1) = Worksheets(1).Cells(b, 2)
Worksheets(1).Range("C" & Range("C65536").End(xlUp).Row + 1) = Worksheets(1).Cells(c, 3)
Worksheets(1).Range("D" & Range("D65536").End(xlUp).Row + 1) = Worksheets(1).Cells(d, 4)
Worksheets(1).Range("E" & Range("E65536").End(xlUp).Row + 1) = Worksheets(1).Cells(e, 5)
Worksheets(1).Range("F" & Range("F65536").End(xlUp).Row + 1) = Worksheets(1).Cells(f, 6)
Worksheets(1).Range("G" & Range("G65536").End(xlUp).Row + 1) = Worksheets(1).Cells(g, 7)
Next g
Next f
Next e
Next d
Next c
Next b
Next a
End Sub
-------------------------------------------------------------------------
Thanks in advance again