The attached sheet and macro code creates output tabs as if both input tabs (pm and rm) were always going to have the names pm and rm. I am wanting the macro to run against whatever tab is currently active only, regardless of the name. In the output tab, I also need two (2) new empty columns (between C&D) named LegType, and Leg#, respectively. Assistance is greatly appreciated.
Public Sub CopyTradeHistory() Dim wks As Worksheet Dim vSheets() As Variant Dim vSheetname As Variant Dim rngSrc As Range vSheets = Array("pm", "rm") On Error Resume Next Application.DisplayAlerts = False Application.ScreenUpdating = False For Each vSheetname In vSheets Set wks = ActiveWorkbook.Worksheets(vSheetname) Set rngSrc = wks.Cells.Find("Account Trade History") Set rngSrc = wks.Range(rngSrc, rngSrc.End(xlDown).End(xlDown).Offset(0, 11)) ActiveWorkbook.Worksheets(vSheetname & "_output").Delete Set wks = ActiveWorkbook.Worksheets.Add wks.Name = vSheetname & "_output" rngSrc.Copy wks.Range("A1") Next Application.ScreenUpdating = True Application.DisplayAlerts = TrueEnd Sub
Option ExplicitPublic Sub CopyTradeHistory() Dim wks As Worksheet Dim rngSrc As Range Dim strSheetname As String On Error Resume Next Application.DisplayAlerts = False Application.ScreenUpdating = False Set wks = ActiveSheet strSheetname = wks.Name Set rngSrc = wks.Cells.Find("Account Trade History") Set rngSrc = wks.Range(rngSrc, rngSrc.End(xlDown).End(xlDown).Offset(0, 11)) ActiveWorkbook.Worksheets(strSheetname & "_output").Delete Set wks = ActiveWorkbook.Worksheets.Add wks.Name = strSheetname & "_output" rngSrc.Copy wks.Range("A1") Application.ScreenUpdating = True Application.DisplayAlerts = TrueEnd Sub
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
Open in new window