engbhs

New Member
Joined
Mar 10, 2012
Messages
5
<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.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top