Getting Range To Step Through In A Loop
Apr 6, 2012
This little piece of code is where I'm having problems.
A36:A45 will always be the same.
The problem is in getting ("R2:AA2") to move to ("R3:AA3") ...
What needs to happen for the loop to work?
Code:
Worksheets("List").Select
Range("A36:A45").Select
Selection.Copy
Worksheets("Month").Select
Range("R2:AA2").Select
I've tried:
Dim rngDC as Range
then Set rngDC = Worksheets("Month").Range("R2:AA2")
So that I can later use rngDC = RngDC.Offset(1,0)
However, when I try rngDC.Select I get an error saying I can't select the variable that way.
Here's the complete code:
Sub Import()
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
With Sheets("Month")
[Code] ....
View 2 Replies
ADVERTISEMENT
May 7, 2006
I'm trying to run a loop that doesn't go through every value between the lower and upper bounds so am using Step at the end of the For line:
For j = 0 To s Step loop_step
'Does stuff in here - not relevant
Next j
The amount that is being stepped through is set as a variable previously - called loop_step, and works fine for small values (e.g. stepping through 10 at a time) but comes up with an error for 1000. I haven't checked how large the value needs to be before it creates an error, but I was wondering if anyone knew if there's a limit on the number you can step through? Otherwise I have no idea what's causing this problem!
View 6 Replies
View Related
Jun 5, 2008
I don't know what exactly is happening, but every step of the macro is happening every 1 second. Literally, the BPM is 60. It will execute a step in the macro every second, when in other macro's i've made, it zips right through as if it was on fast forward.
View 9 Replies
View Related
May 26, 2008
I get a report that I have to manually edit everyday. I've done some VBA, but not sure where to start with this one.
The attachment has two sheets, first is what I get and the second is what I want. I'll explain the process i have to go thru now and maybe I can get some help to automate it.
First
-Add the tech number to the first column for each job for each tech.
7988 us the first tech number.
-Then delete every row that isn't a job.
-Add a column with the install date.(report data near the top.)
-Add a column and populate it with the system, which is the sheet name.
Thats why its example.
View 14 Replies
View Related
Dec 7, 2006
I am looking at the code in a MODULE, I can use "F8" to step through it.
But if I have no module just the main project code I cannot find a way to step through it.
View 9 Replies
View Related
Sep 24, 2007
I have written this code to change the colour of a row of cells to bright green and to change the cell contents of cell(Row, 15) from “L” to “F”: This is the main workbook into which are pulled values from three others. I then want it to open one of the subsidiary workbooks, that feeds the information, to change the same job row to bright green and to change the cell contents of cell(Row, 15) from “L” to “F”. Then I want to save the changes and return to the main sheet: - The ActiveCell contains the Job Number.
Option Explicit
Public rw As Integer
Public Col As Integer
Public Job As String
Public JobNo As String
Public RowNo As Integer
Public wName As String
Public times As Integer
Public Pips As String
Public Nicolas As String
Public Cindys As String
Public wb
Sub FinishedinOfficeCindy()
.
rw = ActiveCell.Row
JobNo = ActiveCell
Col = ActiveCell.Column
If Col 1 Then
Check that the correct
MsgBox "Please choose the Job Number first"column is selected and
Exit SubThat the workbook is
End Ifthe correct one
If Cells(rw, 14) "Cindy" Then
MsgBox "Wrong Secretary Chosen - whoops!"
Exit Sub
End If
All works perfectly when I step through it but, when it is activated (Ctrl+Shift+C) it opens the other workbook and then seems to end? I even tried putting in delays to see if they would help but they didn’t.
View 9 Replies
View Related
Oct 31, 2007
I do have code, but this thing (which appears on the Excel window, not the VBE window) doesn't seem to be connected to any of my code.
What is this, and what caused it to suddenly pop up on me in Excel?
View 9 Replies
View Related
Jan 12, 2010
My workbook contains several worksheets with queries to external SQL Server database. All queries use background updates. Each query uses a parameter for the SQL query string. The parameter value is obtained from E2 Reports!B4. Manually changing this cell returns results on worksheet Job Summary in range("A6:K6"). This works great!Worksheet Order Details contains a list of job numbers in column B.
I wrote a VBA sub that loops through these jobs, changing E2 Reports!B4 for each job. I then call the Application.RefreshAll function. Finally, I copy "Job Summary!A6:K6" to a row on worksheet Order Summary. If the next job is the same order, I copy with a paste special to add the results.The problem occurs when running the VBA sub. If I step through the code, waiting for the RefreshAll function to finish, the correct values are returned. If I step through fast, without waiting for the RefreshAll, the values for some jobs are copies of the previous job, but other jobs are correct. If I hold the F8 key down or hit the F5 key, all values are the same as the first job.I've tried DoEvents, turning off screen updates, and turning off background updates.
Private Sub
Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Name = "Order Summary" Then ' rj references position on Job Summary sheet Dim rj As Integer ' ro references position on Order Summary sheet Dim ro As Integer rj = 6 ro = 6 ' clear all rows Sheets("Order Summary").Range("a6:a65536").EntireRow.Clear Application.CutCopyMode = False ' turn off screen updating to avoid flicker..........................................
View 10 Replies
View Related
Apr 14, 2007
I have a simple calculation - Say 0-6. What i need to do is, if the value is <7 place a 10 in the cell, or if the the value is <12 place a 5 in the cell, or,
lastly if the value is <21.5 place a 0 in the cell. Is this at all possible - as i can only do it with conditional formatting using colours at present
View 7 Replies
View Related
Mar 11, 2008
Is there a way to loop through a range of numbers, pick the first 24 columns, do some kind of caclulation for each column and row, the start again on column 25 for another 24 columns, perform the same calculation, go to the next set of 24 columns, etc?
I have tried using, for example, AVERAGE(OFFSET(range,0,0,24,24) and that correctly returns the average for the first 24 columns (range being the range of data I am using like D366:HK389). However, unless I manually change the starting column for the next set, it doesn't return the correct result. I have attached a sample data spreadsheet. There are 9 Locations in the spreadsheet where each Location contains a 24x24 matrix.
View 4 Replies
View Related
Apr 4, 2013
I am having trouble with the code for this stepped scale rebate structure
$0 TO $50,000 NET PURCHASES=NO REBATE ISSUED
$50,001 TO $150,000=5% OF NET PURCHASES
$150,001 TO $1,000,000=8% OF NET PURCHASES
$1,000,001 TO $2,000,000=9% OF NET PURCHASES
$2,000,001 AND OVER=10% OF NET PURCHASES
I have the forumula for retro active to 50,000
=IF(O77<50001,"0",IF(O77<=150000,O77*5%,IF(O77<=1000000,O77*8%,IF(O77<=2000000,O77*9%,IF(O77>2000001,O77*10%,)))))
If the customer did 2.5 million. I need a formula that will multiply the first 150,000 by 5%, the next 849,999 @ 8%, the next 999,999 @ 9%, and the remaining 500,000 2 10%. I was thinking of using a min/max function.
View 6 Replies
View Related
May 21, 2009
How do I disable a step in a macro without having to delete it?
View 3 Replies
View Related
Jan 25, 2014
While I try to create a sub - autofilter A column and select the...
- first entry (but not as a unique item, as data may changes weekly) once 1st item filtered - I'd do some function: sum weekly results, and keep only one row with the filtered item (paste special/delete rows)
- than step on next entry and do the same as before
- take these steps till the end of autofilter list, than remove autofilter.
.. with this action, I'd get the sum value of my weekly forecast on each individual items.
I've started as:
ActiveSheet.Range("$A$2:$BN$400").AutoFilter Field:=1, Criteria1:= _
"17963-E050LF"
But criteria should be like .. 1st entry ... 2nd entry ... last entry .. session end .. ?!
View 14 Replies
View Related
Oct 7, 2008
I have a macro in one file which uses an input box where the user types in a subcontractor code to retrieve address and contact details from another file.
If the user inputs the incorrect subcontractor code, an error message box pops up. Currently the user then has to select a button in the original file to restart the macro at the input box stage.
What I want to happen is when ok is selected on the error message, to return to the input box so in my macro below where the error message says "An error occurred - you asked for a subcontractor that does not exist. Please try again." and the user selects OK, I would like it to return to the 'Enter the Subcontractor line and the "Please enter the Subcontractor code" input box reappears.
View 8 Replies
View Related
Apr 27, 2009
My vb code currently creates a new sheet via "Sheets.add". This new sheet has the default name of "sheet1" which I rename as "tempSheet". I then populate tempSheet with data, save as a CVS file and then I remove tempSheet.
If I stay in my workbook and try to execute the code again, the default name of the sheet it now creates is "sheet2" and not "sheet1" - this is a problem becuase my code is trying to rename "sheet1" "tempSheet" and of course it cant.
View 3 Replies
View Related
Oct 8, 2011
The following code was working for me and now no longer works. Also, it works when I step through but not when I run it normally (it stops at the line imeediately following this line:
OrigWB.Sheets("PP&E").Move after:=DestWB.Sheets(DestWB.Sheets.Count) ) regardless of what code it is - even if it is only a message box.
The error message is code execution has been interupted.
******************
Sub PPEMerge()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.StatusBar = "Merging..."
'retrieve source docs:
'PP&E sheets from sec packages
'system beginning and ending balances
[code]....
View 1 Replies
View Related
Jun 11, 2009
I don't understand the relationships that are happening and what the final value would be if for example the PT was Red. I'm confused and was curious how four lines could all equal different values(highlighted).
UpUserPaint = UCase(RegPaint.Value)
Dim icount As Integer
LenRegPaint = Len(RegPaint.Value)
For icount = 1 To LenRegPaint
ValPAint = ValPAint + Asc(Mid(UpUserPaint, icount, 1))
Next icount
If PTRed.Value Then
ColorCompare = Abs(Pallet * (ValPAint + PrdtSeed - LenRegPaint))
ColorCompare = Abs( Round(ColorCompare / PrdtSeed - 7227, 0))
ColorCompare = ColorCompare And 6215971
ColorCompare = ColorCompare Xor 6215971.............................
View 4 Replies
View Related
Sep 7, 2006
I am having trouble with the code for this stepped scale commission structure.
Net Service
$1,1400
Step Scale Comm. %
$0-500 40%
$500-750 45%
$750-1000 47%
$1000-9999.99 50%
Final Commission Paid $ ?
View 7 Replies
View Related
Sep 11, 2006
I have a peice of code which opens up a number of Workbooks (200+) and updates a series of control tables in each. Given our security etc environment, links and external references etc are not possible. The target files must all be standalone and self-sufficient.
The problem I have is that when I run the procedure in question in the usual way, the procedure simply terminates after the first file is opened. No error messages, no distress - it just stops. I have put debugging calls all around the "Workbook.Open" call, and it simply doesn't make it out of the call. There is no Auto_Open code in the workbooks being opened and (as I indicated above) no external links, references or function calls.
What's weird is that if I step through the procedure in the Command Debugger, everything works fine. Even weider, if I complete step-by-step processing on the first target file then I can press "Play" and the code will complete execution and process all the remaining files without error.
I have rebuilt/recreated/re-ordered the target files and even moved them to a different volume.
If anyone has seen this before, or has any idea what the cause may be, or even just a wild idea, I'd love to hear it.
Code segment attached.
*
'*** Process each file in the list provided
'*
For intCounter = 1 To intWBS_Files
Call Debug_Msg("Opening WBS File")
Application.EnableEvents = False
Set wbkThis_WkBk = Application.Workbooks.Open(strWBS_Files(intCounter), 0, False)
Application.EnableEvents = True
Call Debug_Msg(("Opened WBS File:" & Chr(13) & strWBS_Files(intCounter)))
If (wbkThis_WkBk Is Nothing) Then
Call Write_Error_Record("File Open Failed", strWBS_Files(intCounter))
Else
Code continues.....
View 6 Replies
View Related
Jan 15, 2007
I have created a custom Command Bar called "My New Bar"
How can I step through each button in that bar to read the assigned macro names or the Caption names
View 9 Replies
View Related
Jul 24, 2007
I am trying to create a floating bridge bar chart.
Here is my data and I will try to describe as accurately as I can.
FY 2004 operating margin = 14.6% (while FY 2005 and FY 2006 = 11.2% => So the difference is 340bps)
The "bridge" back to 14.6% = 90 basis points for Jimmy'Z, 30 basis points for stock option expense, 30 bps for marketing -- that's 150 bps of the 340 and I'm trying to quantify the rest of the bridge but is there a way to show this in excel with floating bars - that is to say the 14.6% bar will touch the axis but the other 3 data points are not touching the X axis but are in the air in a step formation... ?
View 4 Replies
View Related
Jan 29, 2008
Usually Line Graphs show behavior of a process over time. That is why Excel smoothly interpolates between two values.
I would like to show the influence of some laws on technical requirements. Laws kick-in on a certain date, hence they are NOT smooth.
How to make Line Graphs that jump from one value to the other?
I already tried colums that without a gap and an overlap, but they are out of sync.
For clarification I made an example worksheet in which the question has also been illustrated.
View 3 Replies
View Related
Mar 18, 2008
I have 4 columns. I want to add 100 to all rows in the first column, 150 to the ones in the second, etc. Is this possible? I have Excel 2007.
View 9 Replies
View Related
Apr 8, 2009
I'm matching ISO country codes to country names.
This works great as long as the 'lookup_value' portion of the match fuction matches the 3 digit code on Sheet3.
Is it possible to return my desired result without this matching perfectly.
So a value in 'Sheet1 Column A' that begins A344xxxxxxx will return the same result in 'Sheet1 Column F' as if 'Column A' just had a 3 digit number.
View 2 Replies
View Related
Mar 14, 2008
I am trying to automatically increment a cell value then print the sheet. I need it to increment up to 220, or possible higher, and then print at each increment; 1,2,3,etc. as opposed to typing 1 then print, 2 then print, 3 then print...etc. Can this be done with a macro? I've attached a file if you want to view it (cell J2 of "NEW PART ENTRY" sheet).
View 8 Replies
View Related
Jun 6, 2008
I'm trying to produce step charts like Andy Pope does on his web site using the area chart method. http://www.andypope.info/charts/stepchart.htm. This involves duplicating each of the values in each data series, which is tedious if there are a lot of points. Plus the fact that the area series is offset by 1 from the axis series. Can anyone think of a formula to do this? There are plenty of posts here about deleting duplicates, but I couldn't find much about creating duplicates. I can duplicate row numbers using =CEILING(ROW(),2)/2
View 4 Replies
View Related
Mar 26, 2009
I got a formula from this forum to eliminate duplicate records in a array from 1 column in database. Now I would like to take it one step further and filter out records in the array that do not meet the criteria of being in a particular "Zone" selected by the user by clicking on a ComboBox from cell "AA18".
The first formula is copied to cell "C7":
View 6 Replies
View Related
Jan 29, 2009
My spreadsheet has a grouped graphic that I need to repeat in a variable number of rows. I wrote a macro that copies the grouped graphic from above and pastes and positions it in the newly inserted row.
It works great when I use F8 to step thru, but if I try to actually run the macro, I get an "Paste Method of worksheet class failed." error.
Sub InsertEmployees()
Range("B18").Select
Selection.EntireRow.Copy
Selection.EntireRow.Insert Shift:=xlDown
ActiveSheet.Shapes("Group 129").Copy
Application.CutCopyMode = False
ActiveSheet.Paste
End Sub
View 9 Replies
View Related
Dec 6, 2006
I have to make a macheine cycle chart. I have a column containing Step Names and a column containing step time in whole seconds. I need to paste the step names across Row 1 and whole numbers counting to X down colum A. I then need to have each second represented by coloring the cell, for example, Step 1 is 1 sec. and Step 2 is 2 sec. if "Step 1" is in B1 I need B2 colored then for "Step 2" in C1 i need C3-4 highlighted and so on for a variable number of steps. This is my first question so I hope I was clear enough. With this much programed I will be able to make simple changes to tweak it to fit my needs.
View 2 Replies
View Related
Mar 4, 2009
I have a spreadsheet that will monitor payment schedules, in which both payment frequency and the payment start date are inputted by the user.
As such, to make filling out the column(s) fool-proof, I want to grey out cells in which data should not be entered.
For example, if the payment frequency is every 6th day, and the payments are to begin on day 0, then days 0, 6, 12 (etc) should be left white, whereas the remainder of the cells should be shaded.
I can achieve this using multiple conditional formatting rules in excel2007 with iterations of formulae of the type:
View 14 Replies
View Related