<TABLE style="WIDTH: 317pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=423><COLGROUP><COL style="WIDTH: 317pt; mso-width-source: userset; mso-width-alt: 15469" width=423><TBODY><TR style="HEIGHT: 217.5pt" height=290><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 217.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=290 width=423>Hi Everyone,
I have an excel file with one cover sheet includes sheet names in column A and many sheets which include 2 tables; table 1 for returned defective devices, table 2 for preparing details and cost etc. Sheet name is a string and it is also written in cell R1 for each sheet. Sheets are unique and have exactly the same table format. Thare are 2 separate summary sheetsin the same workbook; 1st for table 1 of each sheet, 2nd for table 2 of each sheet. I wrote a macro which copies and adds these tables to summary sheets. When macro runs from active sheet, go to summary sheet and return to the active sheet again and this repeated a few times in order to complete the necessary operation.
When a user add a new sheet and input new records, he/she can copy and add these new records to the related summary sheet (1 or 2) by pressing the macro button on the new sheet.
</TD></TR><TR style="HEIGHT: 128.25pt" height=171><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 128.25pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=171 width=423>I want to run this macro as a unique for each sheet without changing sheet names manually. How can I revised my macro so the sheet name part of it can be automatically updated according to the new sheet? In other words; when I activate another sheet and run the same macro, it will give true results.
My code is as below:
Sub Macro2()
'
' Macro2 Macro
' Gelen bozuk ürünlerin tümünü bir listede toplar.
'
' Keyboard Shortcut: Ctrl+Shift+G
' Sheets("sheetname").UnProtect userinterfaceonly:=true
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R1C18"
Selection.Copy
Sheets("GELENLER").Select
Range("f65536").End(xlUp).Offset(1, -5).Select
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C1"
Range("A7:B13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("f65536").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C29"
Range("AC7:AC13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("g65536").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C6"
Range("F7:F13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("h65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C26"
Range("Z7:AA13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("I65536").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
[F1:F65536].SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Application.Goto Reference:="R1C5"
Selection.End(xlDown).Select
ActiveCell.Offset(0, -4).Select
Selection.End(xlUp).Select
Selection.Copy
ActiveCell.Offset(0, 3).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, -5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub
</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=20 width=423>Your prompt reply would be highly appreciated.</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=20 width=423>Thanks in advance!</TD></TR></TBODY></TABLE>
I can send screenshot of my file but I don't know how in this forum.
I have an excel file with one cover sheet includes sheet names in column A and many sheets which include 2 tables; table 1 for returned defective devices, table 2 for preparing details and cost etc. Sheet name is a string and it is also written in cell R1 for each sheet. Sheets are unique and have exactly the same table format. Thare are 2 separate summary sheetsin the same workbook; 1st for table 1 of each sheet, 2nd for table 2 of each sheet. I wrote a macro which copies and adds these tables to summary sheets. When macro runs from active sheet, go to summary sheet and return to the active sheet again and this repeated a few times in order to complete the necessary operation.
When a user add a new sheet and input new records, he/she can copy and add these new records to the related summary sheet (1 or 2) by pressing the macro button on the new sheet.
</TD></TR><TR style="HEIGHT: 128.25pt" height=171><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 128.25pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=171 width=423>I want to run this macro as a unique for each sheet without changing sheet names manually. How can I revised my macro so the sheet name part of it can be automatically updated according to the new sheet? In other words; when I activate another sheet and run the same macro, it will give true results.
My code is as below:
Sub Macro2()
'
' Macro2 Macro
' Gelen bozuk ürünlerin tümünü bir listede toplar.
'
' Keyboard Shortcut: Ctrl+Shift+G
' Sheets("sheetname").UnProtect userinterfaceonly:=true
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R1C18"
Selection.Copy
Sheets("GELENLER").Select
Range("f65536").End(xlUp).Offset(1, -5).Select
ActiveSheet.Paste
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C1"
Range("A7:B13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("f65536").End(xlUp).Offset(1, -1).Select
ActiveSheet.Paste
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C29"
Range("AC7:AC13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("g65536").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C6"
Range("F7:F13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("h65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Sheets("2-100212-1-2").Select
Application.Goto Reference:="R7C26"
Range("Z7:AA13").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("GELENLER").Select
Range("I65536").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
[F1:F65536].SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Application.Goto Reference:="R1C5"
Selection.End(xlDown).Select
ActiveCell.Offset(0, -4).Select
Selection.End(xlUp).Select
Selection.Copy
ActiveCell.Offset(0, 3).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, -5).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
End Sub
</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=20 width=423>Your prompt reply would be highly appreciated.</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 317pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl64 height=20 width=423>Thanks in advance!</TD></TR></TBODY></TABLE>
I can send screenshot of my file but I don't know how in this forum.