mocnak
04-11-2013, 12:41 PM
hello,
i need to create following macro :
do while (column, row) is not empty
if (row).(column) is not equal (row+1).(column) then
take sheet2, copy and paste it, and paste values from that row to specific cells.
if you find that (row).(column) is equal (row-1).(column) then don't copy and create new sheet but copy those values to sheet with same name.
i tried to find some help here
"stackoverflow.com/questions/2538449/excel-macro-to-create-sheets"
, but still it's not working.
can you help me with it ? or, this code :
Sub Button1_Click()
Dim newsheetname As String
Dim isometry As String
Application.ScreenUpdating = False
Worksheets("Sheet1").Activate
x = 2
Do While Worksheets("Sheet1").Cells(x, 4) <> ""
isometry = Sheet1.Cells(x, 4)
If Cells(x, 4) <> Cells(x - 1, 4) Then
Sheets("template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = isometry 'Sheets(Sheets.Count).Name = isometry
Else
Worksheets(isometry).Activate
If Cells(x, 1) = "07" And Cells(x, 3) = "GDH" Then
Sheets(Sheets.Count).Select
Cells(33, 2) = Sheet1.Cells(x, 4) 'isometry
Cells(33, 28) = Sheet1.Cells(x, 32) 'date
End If
End If
x = x + 1
Worksheets("Sheet1").Activate
Loop
End Sub
and it looks like working, but i get error message when it tries to create new sheet with anme that already exists. can anyone help please ? thanks ...
i need to create following macro :
do while (column, row) is not empty
if (row).(column) is not equal (row+1).(column) then
take sheet2, copy and paste it, and paste values from that row to specific cells.
if you find that (row).(column) is equal (row-1).(column) then don't copy and create new sheet but copy those values to sheet with same name.
i tried to find some help here
"stackoverflow.com/questions/2538449/excel-macro-to-create-sheets"
, but still it's not working.
can you help me with it ? or, this code :
Sub Button1_Click()
Dim newsheetname As String
Dim isometry As String
Application.ScreenUpdating = False
Worksheets("Sheet1").Activate
x = 2
Do While Worksheets("Sheet1").Cells(x, 4) <> ""
isometry = Sheet1.Cells(x, 4)
If Cells(x, 4) <> Cells(x - 1, 4) Then
Sheets("template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = isometry 'Sheets(Sheets.Count).Name = isometry
Else
Worksheets(isometry).Activate
If Cells(x, 1) = "07" And Cells(x, 3) = "GDH" Then
Sheets(Sheets.Count).Select
Cells(33, 2) = Sheet1.Cells(x, 4) 'isometry
Cells(33, 28) = Sheet1.Cells(x, 32) 'date
End If
End If
x = x + 1
Worksheets("Sheet1").Activate
Loop
End Sub
and it looks like working, but i get error message when it tries to create new sheet with anme that already exists. can anyone help please ? thanks ...