Macro: Process The Cells For Every Worksheet In A Book Rather Than Just The Active One

Apr 2, 2007

I need to get this macro to process the cells for every worksheet in a book rather than just the active one


Public Sub test()
Dim Lr As Long, i As Long, x As Range, _
v1 As String, v2 As String, v3 As String
Set x = ActiveSheet.Cells.Find("*", searchdirection:=xlPrevious)
If x Is Nothing Then Exit Sub
Lr = x.Row
Application.ScreenUpdating = False
For i = Lr To 1 Step -1
v1 = Cells(i, 2)
v2 = Mid(Cells(i, 3), 1, 1)
v3 = Cells(i, 4)
If v1 "OP00" Or v2 "L" Or v3 "CC" Then Cells(i, 1).EntireRow.Delete
Next
Application.ScreenUpdating = True
End Sub

View 9 Replies


ADVERTISEMENT

Use ADO To Copy Data From Closed Book To Active Sheet

Mar 6, 2012

I have managed to use ADO to copy data from a closed book to my active sheet. Problem : it copies only the text, and not the dates or figures...

Code:

Sub TestReadDataFromWorkbook()
' fills data from a closed workbook in at the active cell.
GetDataFromClosedWorkbook "H:P&LYE TempDiv P&LP&L Report 020312.xls", "A1:Z1000", Range("A1"), False
End Sub

Code:

Sub GetDataFromClosedWorkbook(SourceFile As String, SourceRange As String, _
TargetRange As Range, IncludeFieldNames As Boolean)
'GetDataFromClosedWorkbook "C:FolderNameWorkbookName.xls", "A1:B21", ActiveCell, False
'GetDataFromClosedWorkbook "C:FolderNameWorkbookName.xls", "MyDataRange", Range("B3"), True

[Code]...

View 4 Replies View Related

Call Macro In Book Two From Book One

Aug 29, 2007

i have done a search on this topic and found many similar answers to many similar questions. All specify using Application.Run "workbookname.xls!macroname".

In my code, the filename has an assigned value as the master code goes out to many secondary files - the user selects the particular one they want at the start of the macro. The variable assigned is called "UpdateKAMsFile".

how do i get the macro called KAMsRandomColour to run in the workbook designated by UpdateKAMsFile?

View 9 Replies View Related

Macro To Highlight Data Inside Other Data Or Move From Book To Book

Jul 16, 2014

so to start off im not able to attach things due to security reasons, what i need is either 1 of 2 macros. if its possible, both are related. one possible is as follows: i need it to go through a certain column (say I for example) and look at the information in it, this information can vary from peoples names along with dates and other stuff, i want it to look through these and if anything has a date today and prior i need the cell to be highlighted. problem is sometimes it might have 2 dates, or no dates. it should have todays date, their name, other information, and future date of something. but not everyone does, this is the macro i dont think that can exists.

2nd macro possibility the other macro uses the first sheet, AFTER been highlighted, normally by hand, and takes it to another workbook and puts in in certain spots. so the first sheet has names of everyone in column K. what i need is it to look at column I and if its highlighted take entire row to other book, and put into sheet under the person name in their tab. the second book has a tab for each person (at this time 18 tabs) which can fluxuate, and each tab is the persons first and last name, without spaces. since when i put sums on main page it didnt want to work with the spaces i had to omit them. again im not sure this is possible.

View 6 Replies View Related

Macro To Change Name Of Active Worksheet?

Mar 27, 2014

Say i have a Worksheet named "gateway" or sometimes it will be "gateway (2)" (3) and so on. Is there a macro that i can call that in some ways calls the active worksheet and renames it to just "gateway" everytime?

View 2 Replies View Related

Making Worksheet Active With Macro

May 12, 2006

Basically trying to make change the active worksheet using a macro code. I want the user to be able to click a button and it will automatically switch the worksheet to another within the workbook.

View 5 Replies View Related

Rename Active Worksheet From Personal.xls Macro

Mar 12, 2009

I am having trouble renaming an active sheet from a Macro I stored in the personal.xls file. I want the active sheet to be renamed to "Data_Source" and then the rest of the code can kick in. Instead of renaming the current worksheet it creates a new one.

View 4 Replies View Related

Macro To Filter Table Using Active Worksheet Name?

Jun 7, 2013

I need the macro to filter a table using the name of active worksheet as criteria. The code that I am writing is as below, but it doesn't seem work:

ActiveSheet.Range("$A$1:$AE$421").AutoFilter Field:=19, Criteria1:="Activesheet.Name"

If I hard quote the name of the sheet then, the macro, unchecks all the criteria in the filter and does not show and row in the table.

View 1 Replies View Related

Macro Code To Change Active Worksheet

May 12, 2006

I have a workbook with about 12 worksheets within it. I am trying to input a button on worksheet 3 that when pushed would activate worksheet 12. Basically the same as if you clicked on the tab at the bottom of the screen called worksheet 12.

I realise that you have to create a button which Ive done. However I cannot seem to figure out the proper macro code to get the button to change the current worksheet when its pushed.

View 4 Replies View Related

Copying An Autofiltered Query From Worksheet A To Worksheet B In The Same Book

Jan 6, 2009

There is an autofilter applied to worksheet A, I would like to transfer only the autofiltered range from worksheet A to worksheet B, a clear worksheet B statement would also help.

View 9 Replies View Related

Macro To Create Pivot Table On Active Worksheet?

Jun 20, 2012

I have recorded a macro to create a pivot table. I thought I had it so that it would create the pivot from the active worksheet only. But looking at the code, it is picking up the sheet name from the one I recorded it from

Code:
Sub SalPiv()
'
' SalPiv Macro
' Macro recorded 20/06/2012 by imccormick

[Code].....

View 1 Replies View Related

Excel Macro (VBA) Sending Active Worksheet In PDF By Outlook

Mar 17, 2014

I find out a code to create a PDF (with opening the Save As dialog box) from an active worksheet, but I can't find out how to send this PDF by e-mail (Outlook). The code is working till the words 'Set OutApp'.

Just what I want is to send the active worksheet as PDF (as attachment) by email (Outlook). Here the present code.

Code:
Sub SendPDF()
'
' SendPDF Macro
'
Dim OutApp As Object
Dim OutMail As Object
Dim v As Variant
v = Application.GetSaveAsFilename(Range("E2").Value, "PDF Files (*.pdf), *.pdf")

[code]....

View 9 Replies View Related

Macro Code Only Works If Specific Worksheet Active

Apr 30, 2008

I have searched the FAQ's but have not found a suitable answer to my problem. I have some code that works perfectly when it is run from the VB Editor but when I put it behind a command button it gives me an error almost straight away. I have read that when a command button is used the command button defaults the active sheet to the one that it is one therefore you always have to specify the active sheet but I have done this so am still confused as to why it is falling over. Below is my code, I have commented where it is tripping:

Sub FormattingAcutalReport()
Workbooks.Open Filename:="H:Risk ReportingDaily TemplatesMF Consolidated Risk DAILY LIVE DATA FROM BO.xls"
Workbooks.Open Filename:="H:Risk ReportingDaily TemplatesDaily Non Banks LIVE.xls"
Dim myBorders() As Variant, item As Variant
Set SEGNSEG = Workbooks("Todays Reports.xls").Worksheets("Seg and Non Seg Bank Summary")............................

View 2 Replies View Related

Make Array Reference Cells On Another Worksheet Of Active Workbook

Feb 27, 2014

My company has complicated time sheets because we have several tasks that are billed differently to different people. Once a month we have to sit down and compile everything from several forms and so forth. I have created a worksheet that pulls all the numbers together so that they can simply be copied and pasted into our reports. The hope was to simply copy this worksheet into a time sheet workbook and it will pull out all of the correct numbers. Although all the time sheet workbooks are set up the same way, whenever I copy the file into another time sheet workbook the program keeps its references from the workbook it was in. Make sense? is there a formula that I can insert into an array to tell it to pull the information from the worksheet with the same name, but in the active workbook?

here is one of the equations I am working with:

{=TRANSPOSE('1st week'!A10:L48)}

so it would look something like this maybe

{=TRANSPOSE('[active workbook]1st week'!A10:L48)} but this doesn't work of course.

View 3 Replies View Related

Getting Runtime Error 9 When Select Group Of Cells In Non-active Worksheet?

Feb 26, 2014

I am trying to select a group of cells in an inactive worksheet from code in a module but I keep getting a run-time error 9 message and I cant seem to find the syntax problem.

I pasted my code below and the error occurs in the last line before the end sub statement.

[Code].....

View 12 Replies View Related

Macro - Paste Formula Into Another Worksheet Using Active Sheet Name As Reference

Jan 9, 2014

I'm using a macro to paste a formulae into a destination cell on another worksheet.

The problem is that I need the Macro to put the name of the active sheet into the formulae

VB:
Sheets("Front").Select
Range("E1").Select
Selection.End(xlDown).Select
Range("E3").Select
ActiveCell.Formula=INDIRECT(ADDRESS(MATCH(9E+99+306,*****ActiveSheet.Name*****!F:F,1),6,4))

The macro has to work whis way becuse I will be using it with multiple worksheets, all with different names.

View 9 Replies View Related

Macro To Go Down Active Cells With Data?

Oct 18, 2012

i have the following macro that copies data from sheet2, sheet 3, sheet 4 and consolidates it into "master" sheet.

Code:

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Dim ofs As Long
If Sh.Name = Sheet2.Name And Sh.Name = Sheet3.Name And Sh.Name = Sheet4.Name Then
ofs = CLng(Mid(Sh.Name, 2)) - 1
Sheets("Master").Range("C9:BB400").Offset(ofs * 500).Value = Sh.Range("C9:BB500").Value
End If
End Sub

i am not well versed with macros

1) the macro is not going to sheet2, sheet 3, sheet 4
2) how can i make my range dynamic. for example, my range is C9:BB400.
-can i make it so the range is C9:BBxxx (where xx is the last active data cell in the range?)

it will prob take a pro a few seconds.

View 3 Replies View Related

Macro To Refresh All Active Cells

Oct 24, 2006

writing a macro that will refresh all the active cells in my "Master" worksheet.

Every month, I append data from one Excel worksheet to the end of my Master worksheet. I want all the cells in the Master worksheet to be formatted as text. However when I copy the cells, I get different formats, i.e. text, general, number, etc. Simply selecting the new data and applying the text format from the Format Cells popup, does not work. I know I need to "re-enter" all the data for the new format to take effect but I really don't want to F2-> Enter thousands of cells.

how to write a macro that will refresh all active cells in a worksheet?

View 4 Replies View Related

E-Mail Just One Worksheet, Not The Whole Book

Sep 25, 2009

I have a workbook with two worksheets. I have an "E-Mail" button within the workbook that, when clicked, emails the entire workbook (using Outlook). The button essentially triggers a macro that makes a copy of the file, opens the dupilcate, mails it, then deletes the duplicate ... all the while the original is still open and not changed at all.

Everything works fine, however I would like to know if there's a way to have the "E-mail" button to just email one of the worksheets. For example, I have two worksheets entitled "WFS" and "CAR". When the email button is clicked, I would like to only have the "CAR" sheet emailed. Here's the code I currently have in place:

View 2 Replies View Related

2000: How To Refer To Worksheet In The Same Book

Nov 12, 2005

I have twelve sheets in the book called "Jan", "Feb" to "Dec". Now I will use value in the two sheets by this format:

Row1 will contain columns, "jan", "feb", and etc.

Row2 should be like "=JAN!b2", "=FEB!b2", etc till "=Dec!b2".

Now the question is, how can I use reference, but not directly put in the sheetname such as "Jan!b2"?

In another word, what I want to use is like "=Worksheets(cells(...))!b2".

View 11 Replies View Related

Log Macro Process

Jun 30, 2006

I need to know if it's possible to log the process of a series of macros
either to txt file or to a Sheet, (either way won't matter but txt file would be perfect)

For example:

Sub MyMacro1 ()
code
End Sub

Sub MyMacro2 ()
code
End Sub

If this process was logged, then the log file would look something like:

Date Time : Sub MyMacro1
Date Time : End Sub
Date Time : Sub MyMacro2
Date Time : End Sub

But it would be a in text just like a log file.
Is this possible with Excel ?

The reason is because my Workbook is huge and I am forever tweaking and adjusting or fixing and I require reference points.

View 4 Replies View Related

Process Of Executing Macro

Aug 30, 2009

I wanted to know If there a way to hide the process of executing macrob (vba)?
I have a long macro that runs on a file and I want to hide the process. I know there is an option to it, I just don't know it.

View 5 Replies View Related

Process Every Nth Row In Macro Loop

Jun 19, 2009

I have the following macro. I need a loop that runs untill there is no more data. The loop should increment at each pass the following 2 Ranges and 1 Rows by 1. What is the VB code that will accomplish this for Excel 2003?

Range("A3:V3").Select
Selection.Cut
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
Range("W2").Select
ActiveSheet.Paste
ActiveWindow.LargeScroll ToRight:=-1
Rows("3:3").Select
Selection.Delete Shift:=xlUp

View 4 Replies View Related

Macro With Reference To Active Chart On Active Sheet

May 14, 2014

I currently have the following macro running to set a chart's data values:

Sub C3Quarter12013()
'
' C3Quarter32013 Macro
'
'
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Values = _

[Code] ......

When I copy the tab and change some of the data within the cells, I want the macro refer to the chart on the current tab and the values in the current tab - as currently it refers to only "Chart 2" and the values in the tab 'Figure 2 - WE OPH'.

I've tried changing the sheet name to ActiveSheet.name but that doesn't seem to work.

View 4 Replies View Related

Move All Worksheets From Book B Behind All Sheets In Book A?

Jul 18, 2014

I made the following code to merge 2 workbooks together.

The code is to be executed when the user has Workbook A opened. (All sheets in workbook KPISWD are supposed to be moved after all worksheets in workbook KPICustomers).

I keep getting a debug error on the code that is supposed to do the actual move and loop until it is finished with all of the sheets in Workbook B.

Code:
Dim KPICustomers, KPISWD As String
KPICustomers = ActiveWorkbook.Name

Workbooks.Open Filename:= _
"W:FacturatieKPI per periode SWD.xls"

KPISWD = ActiveWorkbook.Name

[Code] ..........

View 3 Replies View Related

Copy Data From Book To Book Error

Jun 22, 2007

I have the below code, which now looks to see if a file is open or not, if it is, then copy and past 'Data' and if not open the book and copy 'Data'.

I think the code is sort of right, but im missing something, as i keep getting runtime error when i try and copy. Here is the
Sub PrintSaveKPIUpdate()

Dim sFilName As String
sFilName = "C: estCashSales_KPI.xls"
Set Main = ThisWorkbook

If IsOpen(sFilName) Then

' Book is Open.

Worksheets("Setup Data"). Range("Data").Activate

View 9 Replies View Related

Macro Progress Bar To Show % Process Done

Oct 25, 2008

As i have a pretty "complex" macro, which takes around 20-30 minutes to do (honestly)....

I was wondering if there was a way to create a progress bar just showing me how many % it has done so for?

Or even tell me which sub routine it is up to? (but % would probably be better)

And preferably a pop-up box one?.. not one on the status bar because i have stuff updated on the status bar already...

View 14 Replies View Related

Macro Stop The Delete Process

Oct 12, 2007

I am trying to speed up this macro, ive already tried turning screenupdating and calculation off, but it still takes forever, and I dont understand why.

The code is basically searching for a given string in column E. There are about 9000 lines to my sheet, which shouldnt take more than a 30 seconds to a minute to complete.

Private Sub CommandButton1_Click()
Application.Calculation = xlCalculationManual

For MY_ROWS = Range("E12000").End(xlUp).Row To 1 Step -1
If Range("E" & MY_ROWS).Value UserForm1.ComboBox1.Value Then
Range("A" & MY_ROWS & ":E" & MY_ROWS).Delete (xlUp)
End If
Next MY_ROWS

Also anyone know how to add another condition to make the macro stop the delete process at lets say Range("a1:e8")?

View 9 Replies View Related

Macro To Print Active Area Excluding Cells With Forumula That Doesn't Return Value

Dec 20, 2007

Trying to put together a macro that looks down active sheet for all cells that contain a value, sets a print area and then prints !

Is this possible?

FYG, I have a column that run from 3 - 2000, which contains a formula, which may produce a value depending on corresponding cells.

I used this code from a post on a similar topic, but excel is complaining code
in bold

Private Sub Print_Area_Click()
Dim lastCell As Range
Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 0)
Do Until Application.Count(lastCell.EntireRow) 0
Set lastCell = lastCell.Offset(-1, 0)
Loop
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address
End Sub

View 9 Replies View Related

Select/process Variable Range With Macro

Dec 15, 2006

I download some data from a commercial real estate site about properties and their owners and process it in Excel. Out of 1,000 records, maybe 20 or so will have the data end up in the wrong fields. This is an artifact of the data source the commercial site uses.

Anyway, what I need to do is to get the data back in the right fields. So, I sort the data to pull together at the top of the sheet all the records with data where it's not supposed to be. So far, so good.

Now from one data download to another the number of records which end up in the sort will be different. And, here's the problem.

I try to record a macro mimicking my selection of the range of the data that needs to be moved. Fine, no problem. And, on the same dataset it works like a charm. But as soon as I put a different dataset into the spreadsheet with a different number of records that need to be corrected the macro fails.

Apparently, this is because the macro has been defined with a certain range of cells selected in the first data set and this same range is used for subsequent datasets with different numbers of errant records.

Basically, what I'm trying to record in a macro is the Shift/Control End and Shift/control arrow commands. But they don't record as such.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved