Repeating Action In A Macro

Nov 23, 2007

I have a macro that is working fine. It calculates some values based on a SQL database and then copy the values and paste them into another spreadsheet.

However, I need to repeat the same procedure 1296 times.

Please see below the macro.

Sheets("QUERIES").Select
Range("C1").Select
ActiveCell.FormulaR1C1 = "2"
Range("C5").Select
Selection.QueryTable.REFRESH BackgroundQuery:=False
Range("D5").Select
Selection.QueryTable.REFRESH BackgroundQuery:=False
Range("C5:G5").Select
Selection.Copy
Sheets("AWB RANGE").Select
Range("K2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

I need to increment the line #3 (ActiveCell.FormulaR1C1 = "2") that should start with 2 and end with 1296.

Also, I need to increment the line #11 (Range("K2").Select) that should start with K2 until K1296.

The other parts of the macro will not change.

Would you be able please to give me a hand on this explaining how to create a counter to start on 2 and stop with 1296 ?

View 9 Replies


ADVERTISEMENT

Index And Match With Repeating Values Without Repeating First Found Name

Apr 20, 2006

sorting data I use in a workbook for athletics. I've really chopped down my workbook for upload, In the worksheet "Leaderboard" I can call up stats for different lifts, and it finds (in this case) the top 5 lifts and the names for the kids that have those corresponding lifts.

My problem is that when two or more kids have the same lift, it will only call up the name of the first instance of that lift. You can see this in the "Leaderboard" worksheet, and the name "Adams, Andrew" appears for both lifts of 75. I would appreciate any help on how to correct this, as I've searched the Internet for weeks now looking for a solution. I've tried experimenting with different things as well, all to no avail.

View 9 Replies View Related

Loop Through An Action Within A Macro

Nov 19, 2008

I am trying to loop through an action within a macro and require some assistance.

I have the following

View 2 Replies View Related

Action When Macro Is Aborted

May 30, 2009

I have a spreadsheet that when I am running an specific macro and userforms, this one sheet is visible, when the macro is not running, then, the sheet is hidden.

Now, that happens automatically the way that I set up my macro; however, if the macro is aborted, the sheet doesn't hide.

View 7 Replies View Related

Macro To Take Action On All Sheets That Come After Specified Sheet?

May 13, 2014

I have an excel Workbook made up of sheets that are named after months ("May 2014", "Jun 2014" etc). I want to pull data from each sheet that comes after a user specified date.

View 3 Replies View Related

Macro To Disallow Delete Action?

Mar 25, 2013

So I have this worksheet full of formulas that I do not want users to accidentally delete. Now, I know I can use the standard "Protect Sheet" option to not trigger any accidental changes but I would like an additional safety check (since management users will have access to unlock the sheet) via a macro to prompt the user with a message box (with Yes / No options) which essentially asks the user if they are sure they want to delete a cell if the "Delete" button is chosen? If the answer is No, nothing will happen. But if the answer is Yes, it will delete the contents in the cell.

View 1 Replies View Related

Excel 2003 :: Macro For Save As Action

Jul 12, 2014

I have some excel files which should be saved in Excel 97-2003 Workbook format . I am trying to write vba code for that i am struggling at starting . problem is i have 6 excel files which should be saved as Excel 97-2003 Workbook format i don't know how i give 6 files path to code .

View 2 Replies View Related

Repeating Macro

Jul 7, 2008

I have the below macro that I need to have it repeat until the end of the data, I'm not brilliant with how macro's actually work,

Range("A2:Q5").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With

View 9 Replies View Related

Macro - Making Extensive Action Items Log For Work

Apr 11, 2012

I am trying to make an extensive action items log for work.

On Sheet 1, rows 1-3 are blank. Row 4 contains column headers.

Column A: Item #
Column B: Description
Column C: Drawing #
Column D: Conforming
Column E: Nonconforming
Columns F, G, H don't really matter

What I am wanting is to be able to put an "x" or check mark in either column D or E (conforming or nonconforming). Then I want to run a macro with a push button (I know how to make these) that when pushed scans the spreadsheet row by row until it finds the "x" or check in Column E. I want it to copy every instance of this and send it to an Action Item Page that I have temporarily called Sheet 2. (This way I can go here to see all nonconforming issues). I do not want it to remove the information from Sheet 1.

Then, I want to be able to change the "x" or check on the Action Item Page to Column D (back to conforming) and the macro (push button preferably) copy and send that information back to the original spreadsheet in the SAME row it was.

So, in short I want this to be a fluid way of checking off a punchlist of items.

To complicate things even further, if possible, I would like to have several worksheets send information to the one Action Item List rather than just the one.

View 2 Replies View Related

Trigger Macro By Any User Initiated Sorting Action

Jul 26, 2014

I'm using macros to apply some complex sorting criteria. It is also applying some cell formatting specific to the sort criteria being applied.

At the start of each macro, I'm resetting all cell formatting to remove any formerly applied formatting that is not correct for the new sort criteria. Basic stuff.... works fine.

Now I need to ensure all formatting created by any macro-generated sort gets removed if a user applies a sort using any sort function from the Ribbon. (Reset all formatting prior to any 'manually applied' sort).

I can create the macro to reset the formatting, just not sure how to trigger it upon user action.

Is it possible to trigger a short macro to reset cell formatting when a user applies a sort using the Data>Sort, Data>Sort Ascending, or Data>Sort Descending commands from the Ribbon?

View 9 Replies View Related

How To Make A Macro Take Action When Data Meets Certain Criteria

Feb 6, 2010

I am watching 100 stocks when the stock market opens at 9:30 EST. Not all the stocks will come available to buy or sell at 9:30 but will become available at different time intervals, sometimes 10 minutes after the market opens. When a stock opens it is common for it to spike up, then spike down, then go into a "normal" trading pattern, this is called a slingshot pattern.

If I have a predetermined price up or down for 100 stocks, how can I write a macro that will look at the stock prices and if it shoots above or below a certain value it will submit a buy or sell order? (I already know how to submit the buy or sell orders, just need to get an idea of how to get the macro to constantly check the prices and if it meets my criteria to take action.)

Note: I already have a macro running at one minute intervals to collect data. One minute intervals is to long, I need it in second intervals or less to pick up the slingshot pattern. Is this possible?

View 9 Replies View Related

How Do I Get A Macro To Carry On And Keep Repeating

Jan 2, 2007

I have a macro which is shown below.

Range("E1").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("A3").Select
ActiveSheet.Paste
Sheets("Sheet2").Select
Range("I1").Select
Application.CutCopyMode = False
Selection.Copy

What im trying to do is to be able to run the same macro but start on the last cell that I had selected and work on down the sheet until the end. What im also trying to do is to be able to post into next avail line on sheet 1 so it dosent overwrite.

View 9 Replies View Related

VBA Macro To Select Cells With Certain Value And Perform Action On Adjacent Cell

Mar 10, 2014

Converting old reports to usable excel format. I am having trouble using VBA to set up a looping macro that would search Column A for cells with the text string: "ACTIVITY TOTAL". If cell has that value I would like to perform text to column action on the adjacent cell (R0C1). The macro recording for the test to column settings i need is :

Selection.TextToColumns Destination:=ActiveCell, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1), Array(6, 1), Array(7, 1)), TrailingMinusNumbers:=True

I have attached a sample of what I am currently working with. The actual file has roughly 6000 lines of data, so I would like the macro to go through all lines.

Attached File : LoopingVBA.xlsx‎

View 3 Replies View Related

Call Or Go Back To Macro After User Action Such As Clicking In A Cell

Sep 27, 2012

I am about to write a small macro to do a iteration calculation. I would like though for the user to select me a cell so that the macro uses the value in that cell to start calculations. Now, what I think would be the problem is how do I code a "time" or notice an action such as clicking in a cell to continue with the macro.

Would it be by inserting a pause in the code of a certain time so that gives the user time to click and wait for the code to start? If so, how would much time is enough? Is there another thing that could restart the code such as "noticing a click in a cell" command in VBA?

View 1 Replies View Related

Running A Chart Macro On Selected Cells And Repeating It

Feb 5, 2010

I have figured out how to write a macro to make charts for me automatically, but it only runs the macro on the exact same range every time.

I have about 100 different students to make charts for and would really like to find a way to do it more automatically

Is there a way to write a Macro so that I can run the same steps on a different range (same number of rows and columns)?

Edit: having learned from my first post, I am adding more information.

the first chart is from the data in the range from B5-H7
the next chart would be from the data in the range from B11-H13

The charts are not evenly spaced from each other. I will need to select the range (same size) each time.

I can record the Macro, I just can't apply it where ever I want to.

View 14 Replies View Related

Macro To Change Range / Action Depending On Worksheet (range To Autofill)

Sep 17, 2013

Currently my Macro should: Turn off any filtersNumber column A from 1 to 1000 (starting in A14)Drags formula from K14-O14 down to last row of data shown in column Athen puts cursor in last empty cell in column B ready for user to enter data

On point 3 - I want the range to be K14-O14 if active worksheet equals "EXCHANGES" but if its on the "VALUATIONS" tab the autofill range should be L14-P14

I have found bits and pieces of macros on the internet and put them together so if my macro below is not the most effective for my needs but here it is in it's current state:

Here is my macro:

Sub AddNewEntry()
'TURNS OFF FILTER IF FINDS ONE ON
Dim wks As Worksheet

[Code]....

View 8 Replies View Related

Repeating A Macro In A Macro

Jun 4, 2009

I have a spreadheet with a list of numbers in column A. (6000 or so)

I am looking for a macro that will pick up the first number in A1 (is a 6 digit number)

transfer this number into cell A1 in another worksheet, after this part of the macro i will add my macro that will save & print the second worksheet.

However i can't make the macro repeat for Cell A2, Cell A3....... Cell A6000. All of these will be going into cell A1 in the second worksheet.

View 9 Replies View Related

Repeating Macro Column By Column Until It Hits Blank?

Feb 21, 2014

This is for a template for teachers to analyze student testing data. On sheet4, wrong answers in each column are noted by a lack of a + in the corresponding cell. I want to paste the names of the students who missed each question into sheet 5.

I've done it by repeating a filter macro, but I manually copied the following separately for the 75 columns in the template.

Problem #1 - there must be a more efficient code, something that automatically loops to the next column

Problem #2 - the template has 75 columns, but many tests have fewer questions. I'm trying to find a way to stop the loop whenever it hits a blank cell in Row 10 on sheet 4. I've done it with an if/then in the last section on the above code, but where I'm at now, i would have to add that to the code section for each column. Which isn't that big a deal, but I figure there must be a better way.

The relevant portions of the workbook are attached here.

repeating macro until hits blank cell sample.xlsm

View 4 Replies View Related

Macro To Put Repeating Blocks Side By Side

Feb 26, 2008

I have a sheet with a number of repeating blocks copied down.

I would like a macro that when I select the first block, say range "A1:D30", the macro will cut the blocks below and put them side by side, so that I can compare them across.

i.e cut "A31:D60" and put it in "F1:I30" and so on ...

View 9 Replies View Related

How To Set Password For An Action

Apr 27, 2009

How to set a password before executing any action.

For example, I have "cancel" button in my userform. If i click "cancel" it unloads the form. Instead of that i need a password prompt. so when i click the "cancel" button ,it should ask for a password. only if i provide the correct password then only the form should be unloaded.

View 6 Replies View Related

Put A VBA Class Into Action?

May 28, 2014

JSON import to Excel - Stack Overflow

I understand most of what this post is saying, but I don't understand how to put it together in an excel module or class module.

View 5 Replies View Related

Undo Action In VBA

Jul 18, 2006

I have a database in excel which I want only selected users to have edit rights & others should have readonly rights. I have written the following code where a pop up would appear in selected cells warning user for editing the said cell. What I want is when a user clicks yes he should be able to edit it & when he clicks no the cell should get protected.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim rTriggerCell As Range
If Not Intersect(Target, Range("D1:D100")) Is Nothing Then
Set rTriggerCell = Target
Application.EnableEvents = True
If MsgBox("Edit Cell?", vbYesNo)
End If
On Error Goto 0
Exit Sub
End If

View 6 Replies View Related

Mulitple Action When Condition Met

Oct 21, 2008

How do you set the code so that, if a condition is met, then several cells are filled with values?

So far, my code is

HTML If Cells(i, 2) < Cells(i, 4) Then
Cells(i, 5) = "A"
Cells(i, 6) = Cells(i, 2)
End If

View 11 Replies View Related

Cancel A Message Box Pop Up Action

Aug 13, 2009

If I press either the "OK" or "Cancel" button without entering any states in (because I changed my mind and want ALL states in there, or I pressed either button by accident), the macro eliminates ALL the rows because it needs criteria.

Can this code be modified so that the message box does the following...

1. If I press the "OK" button but I haven't entered in any criteria in the message box, bring up another message box saying "you have not entered in any states in" which brings up an "OK" box and brings you back to the original message box.

2. If I hit the "Cancel" button, bring up a message box that says "No states will be removed" with an "OK" button, essentially cancelling the "State" macro portion of the sub, but continuing with the rest of the code in the sub if there is any.

I would like to have this message box work this way even if states were entered in the input box but the user pressed the "Cancel" button anyway.

3. Create a NEW button named "Keep ALL States" which essentially does the same thing as the "Cancel" button. (I'm trying to "idiot proof" this).

View 4 Replies View Related

Comment Out Using VBA - How To Create This Action

Feb 1, 2012

I have created vba which I want to comment out. I totally stumped how to create this action on vba. My current vba code which I want to comment out using vba

Code:
Option Explicit
Sub YearlyInput()
End Sub
'Speeding Up VBA Code
With Application

[Code] .......

View 8 Replies View Related

Cursor Not Stopping While TAB Action?

Aug 24, 2012

I have a for which consists of

2textbox
1 listbox
1 textbox.

While entering the data, the cursor does not stop in the list box and goes directly goes to the next textbox. Autotab is set to true.

View 4 Replies View Related

Personal.xls Is Missing In Action

Feb 25, 2008

Last friday my personal.xls file went missing. I cannot find it anywhere which means I am missing about 10 key macros. While it is not the upset of the century, my problem is that now when I go into Record Macro and try to "Store New Macro in:" -> "Personal Macro Workbook" and then click OK, Excel brings up a msg box that says:

Personal Macro Workbook in the startup folder must stay open for recording.

Click OK and Excel says:

Unable to Record

View 9 Replies View Related

Undo Last Action - Userform

Aug 14, 2008

What i have is a userform which contains textboxes a user can enter or change data in.

What i'd like to do is to have a button called something like "undo last" whereby a user can 'swap' back the last change they made.. does anyone have any idea how i might go about it?

View 9 Replies View Related

Action With Cell Reference

Feb 20, 2009

I have the following problem to solve:

Cell x in col K is filled with a col number e.g. 'V' (validated via validation list).
Cell x in col L is filled with an amount.
How do I get the amount of cell Lx into cell Vx? This to be done only when the amount Lx not equal to zero.

Can this be done with a formula, or do I have to use a macro? I tried to find the solution for both options, but sofar I have nothing that works. Via the Excel help I could not find the solution. I know how to create a macro activated via a button. I prefer automatic filling by Excel.

View 9 Replies View Related

In Cell Drop Down Box Action

Oct 29, 2009

(using excel 2k7)

Is there a way to create an in-cell dropdown list, then when only 1 item is selected an action is done, plus this has to be repeated for at least 20 rows, preferably 200.

I can do it with an activeX combo box, but that will be tedious and looks messy. The form control box's were linked, or at least when I created them.

Data validation is the prefered method for my drop down list. It looks neat and is easy to replicate for 200 rows.

View 9 Replies View Related







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