Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a for loop to get the range between a ,b columns
Dim x,y As Integer NumRows = Range("B3", Range("B3").End(xlDown)).Rows.Count Range("C2").Select For x = 1 To NumRows For y= cells(A).value to cells(B).value 'which code we have to write for comparing a1,b1 are equal or not ActiveCell.FormulaR1C1 = "=Sum(RC[-1]+1)" ActiveCell.Offset(x, 0).FillDown Next Next |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a for loop to get the range between a ,b columns
This compares the cell in column A to the cell in column B on the same row. If there is a match, then the message box will identify which row. Sub rngCompare() lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row Set rng = ActiveSheet.Range("A2:A" & lr) For Each c In rng If c.Value = c.Offset(0,1).Value Then MsgBox "Bingo on row " & c.Row End If Next End Sub "tom" wrote in message ... Dim x,y As Integer NumRows = Range("B3", Range("B3").End(xlDown)).Rows.Count Range("C2").Select For x = 1 To NumRows For y= cells(A).value to cells(B).value 'which code we have to write for comparing a1,b1 are equal or not ActiveCell.FormulaR1C1 = "=Sum(RC[-1]+1)" ActiveCell.Offset(x, 0).FillDown Next Next |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a for loop to get the range between a ,b columns
The below code marks a "Mismatch" in ColC Dim lngRow as Long, lngLastRow as Long lngLastRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row For lngRow = 1 To lngLastRow If Range("A" & lngRow)< Range("B" & lngRow) Then Range("C" & lngRow) = "Mismatch" End If Next If this post helps click Yes --------------- Jacob Skaria "tom" wrote: Dim x,y As Integer NumRows = Range("B3", Range("B3").End(xlDown)).Rows.Count Range("C2").Select For x = 1 To NumRows For y= cells(A).value to cells(B).value 'which code we have to write for comparing a1,b1 are equal or not ActiveCell.FormulaR1C1 = "=Sum(RC[-1]+1)" ActiveCell.Offset(x, 0).FillDown Next Next |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a for loop to get the range between a ,b columns
I'm not clear what you're trying to achieve here. Do you just want to see where items in column A don't match the item in the same row in column B? why were you using the SUM function in column C? for checking mismatches try this:- With Range(Range("B3"), Range("B3").End(xlDown)).Offset(, 1) .FormulaR1C1 = "=IF(RC1<RC2,""MISMATCH"","""")" End With "tom" wrote in message ... Dim x,y As Integer NumRows = Range("B3", Range("B3").End(xlDown)).Rows.Count Range("C2").Select For x = 1 To NumRows For y= cells(A).value to cells(B).value 'which code we have to write for comparing a1,b1 are equal or not ActiveCell.FormulaR1C1 = "=Sum(RC[-1]+1)" ActiveCell.Offset(x, 0).FillDown Next Next |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to write a for loop to get the range between a ,b columns
the question is very similar to Sam's "How to program this" on 25th June at
18:03. please check the many replies already given. "Patrick Molloy" wrote in message ... I'm not clear what you're trying to achieve here. Do you just want to see where items in column A don't match the item in the same row in column B? why were you using the SUM function in column C? for checking mismatches try this:- With Range(Range("B3"), Range("B3").End(xlDown)).Offset(, 1) .FormulaR1C1 = "=IF(RC1<RC2,""MISMATCH"","""")" End With "tom" wrote in message ... Dim x,y As Integer NumRows = Range("B3", Range("B3").End(xlDown)).Rows.Count Range("C2").Select For x = 1 To NumRows For y= cells(A).value to cells(B).value 'which code we have to write for comparing a1,b1 are equal or not ActiveCell.FormulaR1C1 = "=Sum(RC[-1]+1)" ActiveCell.Offset(x, 0).FillDown Next Next |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Match, then Look Left 4 Columns, then Loop to End of Range | Excel Programming | |||
Write variables from a loop, once only | Excel Programming | |||
How to write a vba loop for Excel | Excel Programming | |||
Loop,Compare,Write | Excel Programming | |||
Show one range in a combobox and write the 2nd range! | Excel Programming |