Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


VBA Code To Loop To The Next Row Down

I just need to get it to loop down to the next row

Sub ConcatenateAll()
Dim x As String, rng As Range, cel As Range
With ActiveSheet
Set rng = .Range("B1:AC1")
For Each cel In rng
x = x & cel.Value
.Range("a1").Value = x
End With
End Sub

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
VBA: Loop Through Sheets And Run The Same Code
I am trying get a set of code to run through the sheets in the workbook... All sheets EXCEPT 1 named "Summary".

How can I code the proper statement? This is my current
Private Sub cmdAddDistribution_Click()

Dim ws As Worksheet
Dim lCount As Long
Dim rFoundCell As Range

'check for selected cash flow
If Trim(Me.cboxCashFlow.Value) = "" Then
MsgBox "Please select a Cash Flow."
Exit Sub
End If...............

View Replies!   View Related
Little VBA Tweak To Some Next Row Code
I want this code to only stop on rows where cell K has the value "planned"

Though only if you have the checkbox "Only show planned" checked...

I have all the pieces though no idea how to get started?

Private Sub NextRecord_Click()
Dim r As Long
If IsNumeric(RowNumber.Text) Then
r = CLng(RowNumber.Text)

r = r + 1
If r > 1 And r

View Replies!   View Related
VBA Code To Hide A Row
i want to know is there anyway we can hide a row if the value of a particular cell is 0 ?

Like if a1 = 0 then Row A should be hidden?

View Replies!   View Related
VBA Code To Bold Row Which Contains SUM
I'm new to VBA and needed help with:
I need to 'bold' the row which contains sum, the problem is that the location of the row varies depending on how long/short the report is....
Here is the code I used to bold a particular row:

Range("A14").EntireRow.Font.Bold = True

But instead of A14, i need it to be a row of no more than 5 columns, one of which contains the word 'SUM'.

View Replies!   View Related
Trying To Use Vba Code To Evaluate Each Row In A Highlighted Selection
I have a worksheet (with if statements) that I throw numbers from a report into and it uses those if statements to calculate the number of items and money earned. The problem is that sometimes employees use different key words for their items so the formulas dont pick them up and this skews their results for the month. Also it's hard to see where someone messed so I'm trying to write a code that reads each row for a given selection and calculates the sum and if that sum is 0 then we can look for where the employee made an error. This is what I have:

Dim RngToSum As Range
Set RngToSum = Selection.Rows
For Each Row In RngToSum
If Application.WorksheetFunction.Sum(RngToSum) = "0" Then
MsgBox "Lets play find the error"
Selection.Rows.Interior.ColorIndex = 3 'red
Else Application.WorksheetFunction.Sum(RngToSum) 0 Then
MsgBox "Congrats there's no errors"
End If
End Sub

The problem with the code is that I want it to read every line and if there's no errors then have it say "congrats no errors" after ALL rows have been checked because right now it pulls a msgbox per row and I don't want to go through hundreds of no error msgboxes. However, if even just one line has an error then have a msgbox come up.

Also there's something weird where this code wont pick up an error for a row if i highlight two rows (one row without an error and one with) but if i highlight just rows of zeros then it'll pick it up.

View Replies!   View Related
VBA Code To Select Last Cell In Row With Data
I have a row of formulas that reference other sheets in my workbook (i.e. Cell A4=Sheet2!A1, Cell B4=Sheet2!B1, etc). I need to have VBA find the last cell in that row with data. I tried "End(xlToRight).Column" but it goes all the way to the end because all of the cells have formulas. I need to find the last cell that is empty of data or maybe >0 would work.

View Replies!   View Related
VBA CODE On Pasting On Last Row Of Data For Various Worksheets
I have got a workbook with 20 or more worksheets. Every quarter I need to paste/append new data on these worksheets (which has already got existing data from previous quarters). All worksheets have different rows of data, for eg One worksheet may have 10rows, the other may have 50. Hence when I am writing my code, I cannot specify the destination cell as for eg A11, or A51.

How do I write up a VBA code that looks for the last row of data on these various worksheets and then pastes the new information on the next row(new row).

View Replies!   View Related
VBA Code To Use Same Cell When Row/Columns Inserted
I wanted the title to be " Dynamic Row And Column Index In Macro" but I wasn't allowed to write it so. However, I have macros where I write things like:

.Cells(138, 13).Value = Something

Now, if I add rows and/or columns in the worksheet, (138, 13) might not be the coorect coordinates anymore.

View Replies!   View Related
For Each Loop To Delete Row W/ Value (Loop Backwards)
For Each loop can be instructed to loop starting the bottom of the range. I know that a For To Loop can handle looping from the bottom up,

Sub Filterout()
Dim c As Range
Dim rng As Range
Dim i As Long
Dim lrow As Long
Dim counter As Integer
lrow = Cells(Rows.Count, 3).End(xlUp).Row
Set rng = Range("c2:c36")

For Each c In rng
If Left(c.Value, 1) "~~" Then
End If
Next c

View Replies!   View Related
Using VBA To Select A Row And Colour Code It Based On Conditions
I've had a look through the forum and can't see an answer, so apologies if I'm duplicating something!

I have a spreadsheet where column O has five conditions:
1 PO in
2 High Probability
3 Medium Probability
4 Low Probability

I need to colour code the whole row based on the value in the cells; if there were four conditions, I could do this with conditional formatting, but with five (with white as the fifth condition), I need to look at VBA.

However, I'm having difficulty colouring the whole row; how do I do this?

e.g. what I need to do is:
If O2 = "1 PO in"; Select A2:T2; Colour green

In addition, I need to ensure that if there is no data in column D, but column O is "1 PO in", it is highlighted in a separate colour. I have a macro for that, but don't know whether in needs to be put into the code before or after the macro needed above...

View Replies!   View Related
VBA Code To Lookup Value In Range & Update Cell In Row
I have a function that is called upon saving a UserForm. One of the Text Labels contains the ID field that I need to use to do a lookup into the first column of a Named Range and then I need to update the cell in the 4th column of that row.

From my research, I'm assuming it will go something like this:

Application.WorksheetFunction.VLookup(valve, Worksheets("TestWorksheet").Range("TestRange".Cells), 10, False).Value = "TestValue"

View Replies!   View Related
Loop With Below Code
Loop with below code. I have the below code:

View Replies!   View Related
Code Stops During The Loop
I am using Excel 2003 work PC, and when i run this simple code it stops during the loop, I have had this problem a bit its like something is hitting the esc key or ctrl - break. But no keys are being hit or are sticking.

I have closed Excel and created new work book pasted the code in but it still stops at r = r - 1, haven't done a restart yet.

Sub Macro2()
Dim r As Integer
r = 10
Do Until r = 0
ActiveCell.Value = ("Shut down in " & r)
Application.Wait Now + TimeValue("0:00:01")
r = r - 1
End Sub

View Replies!   View Related
Print Loop Code
I have a print code that I want to run on a loop. In column A Sheet UPSLabels, I have record numbers 1 through 94.

I have a vlookup in "C1" of another sheet that looks at the record number in "B1" and pulls in the correct information from UPSLabels based off the matchin record number in column A. I would like my code to print, update the number in "B1" by 1, and keep printing the records until it reaches 94.

I've probably supplied too much information, but the point is, I need the loop to run until "B1" reaches 94.

Sub print_loop()

Dim cnt As Range
Set cnt = Range("L1")

ActiveWindow.SelectedSheets.PrintOut Copies:=cnt, Collate:=True
Range("b1") = Range("b1") + 1

End Sub

View Replies!   View Related
Loop Code Does Not Stop
I enter 1 record using the form, the next records does not populated correctly. It looks like the code just keeps looping by ....

View Replies!   View Related
Shortening Code With Loop
How would I shorten this code using a loop and arrays? It is working correctly but needs to be shortened down.

Sub cr()
Dim j
Cells(1, 1).Interior.Color = RGB(250, 155, 100)
j = 0.09
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.094
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.043
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.05
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.034
Cells(1, 1).Value = j
Application.Wait Now + TimeValue("00:00:02")
j = 0.032.........................................

View Replies!   View Related
Loop-code To Go Through A List Of Numbers
Im trying to make some code to go through a list of numbers, and pick the next highest number from the one entered in a form. Then I need to do some processing with that number (i need to create a worksheet with that number as the name, and place that number in a few cells on that worksheet, and the main worksheet, but thats all stuff i think i can do).

View Replies!   View Related
Insert Rows Within Loop Code
I have a requirement where I have to add a row with x columns using vba. this is the code I am using now

k = 17
prodetails = .GetFieldValue("Product Details")
sSeats = .GetFieldValue("Seats")
If isRecord Then
While isRecord
Sheets("Products").Rows(k).Insert Shift:=xlDown
Sheets("Products").Rows(k + 1).Insert Shift:=xlDown
Sheets("Products").Rows(k + 2).Insert Shift:=xlDown
ThisWorkbook.Sheets("Products"). Cells(k, Prod6Col) = prodetails
ThisWorkbook.Sheets("Products").Cells(k, Unit4Col) = sSeats
isRecord = .NextRecord()
End If

In this code I have declared Prod6Col and Unit4Col as constants. instead I need to use them as variables like in this modified code. However if i use this code, I get an object definition error.

k = 17
m = 20 (20th column)
l = 18 (18th column)
prodetails = .GetFieldValue("Product Details")
sSeats = .GetFieldValue("Seats")
If isRecord Then
While isRecord

View Replies!   View Related
Efficient Loop Code To Format Labels
I am trying to creat a code that with take the value of an active cell and depending on this value will assign a backcolour to a label corresponding to the cell. so far so good.
I then want the code to offset to the next cell in the range read its value and assign a colour to that cells backcolor.

here is an idea.

for n = 1 to 4
if activecell = "A" then
Label1.BackColor = RGB(0, 0, 0)
if activecell = "B" then
Label1.BackColor = RGB(0, 0, 255)
if activecell = "C" then
Label1.BackColor = RGB(0, 255, 0)
end if
next n

Firstly I would like the next loop (refering to A2 in this example) to refer to Label2 not Label1 and so on.
secondly the example would loop through 4 cells in one row (A1:A4) but I would like the code to apply to several rows ie (A1:D4).

so thats 16 cell and 16 labels. I could code this in a very inefficient way but I am sure ther is a simple method.

View Replies!   View Related
Code Loop Through Two Tables Checking And Altering
I have two tables of information. The first is a matrix with some distances. The second is a table of distribution. Ive been trying this for a long time now with limited success using a truth table but i've realised the only way to do this is in code. Ive got limited experience with this so please point me in the right direction.

Ive written some steps explaining what each table does here -

Step 1Check for lowest value B4:F4 in Table 1 (in example is 10)
Step 2Check corresponding column destination available capacity in table 2 (Example 500)
Step 3Distribute as much as possible from source in table 2 (500)
Step 4Reduce value in capacity line by value taken from source
Step 5If some source remains move back to table 1 and find next nearest column Dest
Step 6Repeat step 2 until all source is gone in row
Step 7 Check for lowest value B5:F5 in Table 1
if run out of capacity at all sites stop code
until Table 1 column B is empty

Ive posted a spreadsheet with some before and after tables in it aswell. Its very small and formatted o its easy to see whats happening.

View Replies!   View Related
Code To Find Duplicates In Worksheets And Loop
I am trying to write a macro that will find duplicate listings in two worksheets by row. I don't really want to do a user form unless I have to.

View Replies!   View Related
Code Executes 8 Times Without Loop Statements.
I was playing aroung some VBA code, but the code executes 98 times and I don't know why. For example, range A1 contains 5. When I type, say 3, in A1, I want A1 to show me 8 (5+3). Then I may type 10, in this case A1 must show 18 (8+10). And so on. I decided to place entered values in different column, then sum them in A1 with below stated code

View Replies!   View Related
Code Doesn't Loop Properly **
I have some code (probably a little inefficient, but still) that should delete any rows that contain nothing in column V. My problem is that it only deletes 1 row at a time:

Dim c As Long
Dim Limit As Long
Limit = Cells(Rows.Count, 11).End(xlUp).Row
For c = 2 To Limit
If Cells(c, 22).Value = "" Then
Cells(c, 22).EntireRow.Delete xlUp
End If
Next c

View Replies!   View Related
Loop To Replace Dropdown Clear Code
I have this code on a tab containing a series of dependent dropdowns. There are two dropdowns in each row, Dropdown2 being dependent on the choice in Dropdown1. This code replaces any contents of Dropdown2 with "Select..." if Dropdown1 changes. (Dropdown1 and Dropdown2 are NOT names, those are just the way I refer to them).


View Replies!   View Related
Macro Code Sticks In Continuous Loop
The situation is that I get a report on a daily basis with many account numbers included in it. I am only concerned with 22 of them. What I am trying to do is look at each account number and compare it to account numbers I have defined in the array. If the account is found then advance to the next row and begin the search again. If the account is not found in the array, then delete that row. Once I have told excel to delete the row, I also tell it to stay on that same row and continue the search. For instance if row 5 did not contain an account number in my array, then that row will be deleted, but since the row is deleted, row 6 just became row 5.This bit of code seems to also cause my code to stay in the loop.

I need to tell excel that if there is no more information to be evaluated, then exit the For Each statement. I donft want to exit the sub, because I need to add additional code, I just need it to exit the loop.

Sub SortFailRpt()
Dim lFailRows As Long
Dim Ary() As Variant
Dim x As Integer, AryIndex As Integer
Ary = Array(1843, 1844, 1845, 1847, 1906, 1907, 1940, 1967, 1982, 1983, 1984, _
1985, 1986, 1987, 2045, 2087, 2088, 2096, 2106, 2108, 2109, 2110)
lFailRows = ActiveWorkbook. Sheets(1). Range("A65536").End(xlUp).Row
For x = 2 To lFailRows
On Error Goto NotFound
For AryIndex = 0 To 21
If ActiveWorkbook.Sheets(1).Range("B" & x).Value = Ary(AryIndex) Then
Goto NextVar
End If
Next AryIndex
ActiveWorkbook.Sheets(1).Range("B" & x).EntireRow.Delete
x = x - 1
Next x
End Sub

View Replies!   View Related
Column - Row Loop
I am trying to loop through columns and rows to get the sum of each and delete that column that equals zero. I have-

Dim lastrow
Dim r, c As Integer
Dim RowSum
RowSum = 0

lastrow = Selection.Rows.Count

For r = 2 To 80
For c = 2 To lastrow
RowSum = RowSum + ActiveSheet.Cells(r, c).Value ' here I get error Application-defined or object-defined error

Next c
If RowSum = 0 Then
ActiveSheet.Cells(r, c).EntireColumn.Delete
End If
Next r

What am I doing wrong?

View Replies!   View Related
How To Move To The Next Row In A Do Loop
In a macro I made, I have a do...while loop:

Do While Not objXLworkBook.ActiveSheet.Cells(nSequence, 1).Value = gcstrEMPTYSTRING

.....bunch of code


In my file, the second row of data always contains blanks (i.e., I've got a HDR record, blank row and then rows of data). How do I make my code bypass that empty row of data and then continue processing all other records?

Should I put a "move to next record" in my bunch of code, and if so, how do I do that?

View Replies!   View Related
Add New Row In Loop
I now wonder is it possible to add Text in the row above and below the loop can this be done? Like below?

Test 1 Test
Test 2 Test

View Replies!   View Related
Code For File Directory Loop - Use Of Application.Filesearch

I have been trying to process Excel files in a directory with the following

Sub FindExcelFiles()
Dim foldername As String
Dim FSO As Object
Dim fldr As Object
Dim file As Object
Dim cnt As Long
foldername = "c:usersseagreendesktopTuesdayFeb102009week ending feb 7 2009 esting2"
Set FSO = CreateObject("Scripting.FilesystemObject")
Set fldr = FSO.GetFolder(foldername)
For Each file In fldr.Files
If file.Type Like "*Microsoft Office Excel*" Then
cnt = cnt + 1
End If
Application.StatusBar = "Now working on " & ActiveWorkbook.FullName
DoSomething ActiveWorkbook
Next file
Set file = Nothing
Set fldr = Nothing
Set FSO = Nothing
Range("A1").Value = cnt
End Sub
Here's the stub for the subroutine that's being called:

Sub DoSomething(inBook As Workbook) 'Massage each workbook
'Debug.Print "Hello"
Debug.Print ActiveWorkbook.FullName
End Sub
I am using Excel 2007. I found out I cannot use Application.Filesearch as Microsoft has dropped this method for 2007. My problem now is that I just see "Now working on c:usersseagreendesktopTuesdayFeb102009week ending feb 7 2009 esting2file1.xls written six times in the immediate window.

View Replies!   View Related
Loop Without Vba
if it was possible to make a loop without using VBA?

I have the following problem:
If the value of "J14" > 50; then I want to increase "J2" until "J14" < 50

Is this possible without VBA??

See attachment for details:

View Replies!   View Related
SUMIF And LOOP Till The Last Row
How would one go about creating a macro that would sum values in column G based on a condition in F ( a "SUMIF" basically) until the end of the range?

The condition would be so that the first blank cell in Column G (starting from column G9 ie Range("G9").End(xlDown).Offset(1,0) would contain the sum of everything above up until the word "Total" (or even the string of 5 characters from the left say "Total") appear in Column F - (the word Total appears a few times in column F, so it should detect the first applicable one)

The idea would be to have this repeated / looped until the end of the data range

Attached is an example and I hope what I have written makes sense

As for the worksheets:

"Final" is what it should look like (Blue Cells represent manual calculations)

"Working" Sheet is where I have it up to now

The sheet "Original" has a button that recreates everything up until where "Working" Sheet is

Sheet ("Tenant History Schedule") is scrap sheet

View Replies!   View Related
Loop Command Until Blank Row
to get the code myself but nearly smashed the computer , then been searching for hours for the answer and still no luck, so last resort, to what I bet is an easy solution.

I'm building a spreadsheet and want to create a macro that will copy a row to another spreadsheet, and continue repeating this until it reaches a blank row and then stops the macro. For example:-

Row 1 contains Anna
Row 2 contains Ben
Row 3 contains Clive
Row 4 contains nothing

I want excel to copy rows 1, 2 and 3 to another workbook but once it reaches row 4 it realises it's reached the end of the list. (The list won't always be three rows but will be continous)

View Replies!   View Related
Loop To Delete Empty Row
How do I make a loop to delete a row if the cell A is empty. Example: If cell A3 was empty I want it to delete the row. If cell A4 had data I would like it to skip that row and go on to cell A5.

View Replies!   View Related
VBA Macro Code Needed To Run The Code Contained Within A Cell
I have a macro that, when run, needs to read the contents of cell B5, and run the code that it contains.

Cell B5, for example, would contain the text:
Range("B13").Formula = "SUM(D12:D14)"

I need a macro to "execute this code", as if it were in the macro itself.

I have assigned the above to a variable, but am not sure how to execute it.


Dim the_calc
the_calc = Range("B5").value

Now, how do I run the_calc ?

View Replies!   View Related
Code That Gets Stuck In The Loop And Will Not Stop Unless I Press The Esc Key
I have the following code that gets stuck in the Loop and will not stop unless I press the Esc key:

Sub WIP()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long
Dim newRow As Long
Set ws1 = Sheets("PAYCALC")
Set ws2 = Sheets("WIP")

Application.ScreenUpdating = False
With ws2
.Range("A2:C" & .Range("A2:C2").End(xlDown).Row).Clear
End With

x = 10
lastrow = ws1.Range("C5").End(xlUp)
newRow = ws2.Cells(65536, 1).End(xlUp).Offset(1, 0).Row
ws2.Cells(newRow, 1) = ws1.Cells(x, 2).Offset(-2, 0).Value
ws2.Cells(newRow, 2) = ws1.Cells(x, 2).Value
ws2.Cells(newRow, 3) = ws1.Cells(x, 2).Offset(3, 0).Value
x = x + 21
Loop Until x >= lastrow

There's a twist to this. I have the same identiclecode in a different module. The only difference is ws2 is different and there are 7 newRow's. Other then that the two are the same.

That one works just fine without getting stuck. It will go through 200+ sets of records and stop when it reaches the last one.

The one above will not stop even though I just put in three records on ws1 for testing.

View Replies!   View Related
Copy Method Of Worksheet Class Failed In Loop Code
I have an excel sheet being used as a mini database table.Rows = records, columns = fields. I have some VBA to create a copy of base template in the workbook, then populate the new template with the data from a row/record in the db. I currently have about 100 records. After about the 57th record I recieve RT error 1004. "Copy method of worksheet class failed". I think this is becuase excel is running out of memory. My laptop has 1gig of ram, and i have closed all other apps when running the macro.

Is there a way to free up memory while the vba is running, without clearing my "for" or count position which tells the macro to create a new sheet and which row/record in the db to populate the data in the new sheet.

View Replies!   View Related
VBA Matching >1 Value In A Loop?
If the following macro matchs two ID numbers from column B in column C it shoud highlight them green.

Column C may has multiple entries of column B, however the macro i have written appears to only match the first ID number found in column C from B.

I think this may have something to do with my loop, can anyone suggest a solution?

Sub colour_filter()

Dim myrange As Range
Dim Rng As Range
Dim rng1 As Range
Dim a As Integer

Set Rng = ActiveSheet.Range("B2", Range("B" & Rows.Count).End(xlUp))
Set rng1 = ActiveSheet.Range("C2", Range("C" & Rows.Count).End(xlUp))
a = 0

For Each myrange In Rng
If IsNumeric(Application.Match(myrange.Value, rng1, 0)) Then
rng1(Application.Match(myrange.Value, rng1, 0), 1).Range _
("A1", Cells(1, Columns.Count).End(xlToLeft)).Interior.color = vbGreen
a = a + 1
End If
Next myrange

MsgBox "Number of matches: " & a

End Sub

View Replies!   View Related
Code Clears A Sheete Starting At Row 7 And Leaves The Last Row
The below code clears a sheete starting at row 7 and leaves the last row. I want to validation that if the only row with text is the starting row then I dont want the delete rows to happen

Sub clearRecap()
Range("a7", Range("a" & Rows.Count).End(xlUp).Offset(-1)).EntireRow.Delete
End Sub

View Replies!   View Related
Offset Down One Row And Loop (Monte Carlo)
I need to copy the value from cell Z18 and then use the function 'paste values' to input the data in cell B24.

Having done this I need the sheet to recalculate and generate a new set of random numbers. I then require the new value in cell Z18 to be copied and pasted in the next row of column B, cell B25.
I need this process repeating for 10,000 iterations so that the range B24:B1023 is filled.

Here is my code, it will recalculate cell Z18 and return the value in cell B24, but will not offset down one row and loop.

View Replies!   View Related
Loop Through Worksheet Delete Row Until Specific Value
I'm trying to loop thru the worksheets(which are imported from a web form in Outlook) and delete row 31 until the text "PARTS" is reached.
I need to do this to format each sheet exactly for export to an Access database. The code below works when I step thru it but when I save and run from a button it gets stuck in an endless loop. Any help would be greatly appreciated.

Sub DeleteRow31()
Dim w As Worksheet
Dim rng As Range
For Each w In Worksheets

Do Until Cells(31, "B") = "PARTS:"
If Not Cells(31, "B") = "PARTS:" Then
End If
Next w
End Sub

View Replies!   View Related
Loop Return The Result Back In Row
Col ACol BCol CCol DCol ECol F
row 2531IN COMMAND#N/A
row 2631IN COMMAND#N/A

I have 5 coulmns of data and in col F I have the following formula in row 18
the results come back " TAX CONSIDERATIONS"
however the same results comes back in row 21 and row can I modify this lookup to change when column B changes

View Replies!   View Related
Eliminate Rows (loop To The End Of Each Row)
I'm trying to write a macro that will loop to the end of each row, if the last cell is a number it will cut and paste that whole row into another sheet, if the last cell is a word then it will leave it as it is.

View Replies!   View Related
Process Every Nth Row In Macro Loop
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?

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
ActiveWindow.LargeScroll ToRight:=-1
Selection.Delete Shift:=xlUp

View Replies!   View Related
Delete Row And Loop Based On Condition
i have a set of data as below and wish to delete ENTIRE ROW if cell is the same but keep the first entry when code comes to in the data set below excel would keep first row and delete 2nd,3rd,5th, 6,7,8 and then go to next unique identifier which would be AU0000LIFHB3 this would not be deleted as it is unique the would proceed to AU300GPTC011. this process would then stop when no data was available


View Replies!   View Related
Assign Loop Counter To Range Row
How do you assign a loop counter value to a range row value? Scenario: Add cells from a column that arent successive. SUM C10 + C17 + C24 etc

Private Sub CommandButton1_Click()
Dim total As Integer
Dim counter As Integer
For counter = 10 To 700 Step 7
total = total + Range("Ccounter")
Next counter
End Sub

View Replies!   View Related
Loop Over Rows And Delete Row If Value Not In Table
I have two worksehets. The first worksheet contains data on products. The product code is in column A. My second sheet contains a list of product codes in column a. I want to delete all rows in worksheet 1 where the product code doesnt exist in the list in worksheet 2. Can someone provide a outline for a macro to loop over sheet one and look up the value in worksheet 2 and delete the row from worksheet 1?

View Replies!   View Related
Loop To Delete Row When Criteria Is Met
I am using this to delete rows from my excel sheet. I basicaly start my script by placing xxx in cell B2000. I want to optimize my code and maybe some how tell excel do until last cell. I am playing with:

"Do Until lLastRow = Range("B" & Rows.Count).End(xlUp).Row"
But not shure how to procede with this.

Do Until ActiveCell = "xxx"
If ActiveCell = "Ticket" Then
ActiveCell.Offset(1, 0).Select
End If

View Replies!   View Related
Loop Through Cells On 1 Row Of Column Range
I am trying to create a loop in which the code "reads" ... lets say... cell F5. Determines if cell F5 = 1. if not, it moves on. only, instead of moving to cell F6, it moves to cell G5. so i need to add one to the column letter. How is this best achieved? having trouble with this. adding a letter to it concatinates them, and adding numbers, well its a mismatched type so that simply does not work.

View Replies!   View Related
Modify The Formula Entries In The Following Code To Cycle Or Loop Through All Checks Required
I'm working on a spreadsheet to compile and print checks. All the check information except the date and first check number is contained in a Wins sheet. I also have a Checks sheet which contains a master check. I used text boxes on the master check to contain individual check information. Each text box is filled in from the Wins sheet by means of formulas. The problem I'm having is how to modify the formula entries in the following code to cycle or loop through all checks required. A sample spreadsheet is attached.

View Replies!   View Related
Prevent Code Loop Interruption By Esc Or Ctrl+Break Keys
The code itself functions as desired however i am getting the vba message "code execution has been interupted". However if i comment out the line

ActiveSheet. Range("Y6:BC6").Delete Shift:=xlUp. Then all is well - so i'd say that is the culprit.

Sub Test()
If Left(ActiveSheet.Name, 5) = "query" Then
Dim intRow As Integer
intRow = ActiveSheet.Range("Y4").End(xlDown).Offset(1, 0).Row

If intRow > 25 Then
ActiveSheet.Range("Y6:BC6").Delete Shift:=xlUp
intRow = intRow - 1
End If
' Runner 1
ActiveSheet.Range("Y" & intRow).Value = ActiveSheet.Range("A5").Value
ActiveSheet.Range("Z" & intRow).Value = ActiveSheet.Range("M4").Value...................

View Replies!   View Related
Copyright 2005-08, All rights reserved