Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Newbie's question.

Hi everybody,

I don't know how to compare 2 cells. If I refered to a cell, like A1 and
compare it to D1, how I must write the line because my loop will always
referd to A1. I have the same problem when I want to insert a partial row,
it will be always at D1:G1.

Sub Macro1()
Range("a1").Activate
Do until ActiveCell.Value <0.01
'Cell A1 = cell D1?
If Range("a1") = Range("d1") Then
'Cell B1 = cell E1?
If Range("b1") = Range("e1") Then
'Cell C1 = cell F1?
If Range("c1") = Range("f1") Then
'Return to A2
ActiveCell.Offset(1, 0).Select
End If
End If
Else: Range(d1:g1).Activate
'Insert a partial row at D1:G1 to move date
Selection.Insert Shift:=xlDown
'Go to G1 and write Change
ActiveCell.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = "Change"
End If
Loop
End Sub

Thanks for your help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Newbie's question.

Is this what you want

Sub Macro1()
Dim i As Long

With Range("a1")
Do Until ActiveCell.Value < 0.01
'Cell A1 = cell D1?
If .Offset(i, 0) = .Offset(i, 3) Then
'Cell B1 = cell E1?
If .Offset(i, 1) = .Offset(i, 4) Then
'Cell C1 = cell F1?
If .Offset(i, 2) = .Offset(i, 5) Then
'Return to A2
End If
End If
Else
.Range(Cells(i + 1, 1), Cells(i + 1, 7)).Insert
Shift:=xlDown
'Go to G1 and write Change
.Offset(i, 6).Value = "Change"
End If
i = i + 1
Loop
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linebaker" wrote in message
.. .
Hi everybody,

I don't know how to compare 2 cells. If I refered to a cell, like A1 and
compare it to D1, how I must write the line because my loop will always
referd to A1. I have the same problem when I want to insert a partial row,
it will be always at D1:G1.

Sub Macro1()
Range("a1").Activate
Do until ActiveCell.Value <0.01
'Cell A1 = cell D1?
If Range("a1") = Range("d1") Then
'Cell B1 = cell E1?
If Range("b1") = Range("e1") Then
'Cell C1 = cell F1?
If Range("c1") = Range("f1") Then
'Return to A2
ActiveCell.Offset(1, 0).Select
End If
End If
Else: Range(d1:g1).Activate
'Insert a partial row at D1:G1 to move date
Selection.Insert Shift:=xlDown
'Go to G1 and write Change
ActiveCell.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = "Change"
End If
Loop
End Sub

Thanks for your help




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Newbie's question.

Hi Bob,

I tried it but when A1 < D1 it jump to the end sub and didn't insert the
word "Change" in G1. How to do this.

Thanks very much Bob for your help.

"Bob Phillips" a écrit dans le message
de ...
Is this what you want

Sub Macro1()
Dim i As Long

With Range("a1")
Do Until ActiveCell.Value < 0.01
'Cell A1 = cell D1?
If .Offset(i, 0) = .Offset(i, 3) Then
'Cell B1 = cell E1?
If .Offset(i, 1) = .Offset(i, 4) Then
'Cell C1 = cell F1?
If .Offset(i, 2) = .Offset(i, 5) Then
'Return to A2
End If
End If
Else
.Range(Cells(i + 1, 1), Cells(i + 1, 7)).Insert
Shift:=xlDown
'Go to G1 and write Change
.Offset(i, 6).Value = "Change"
End If
i = i + 1
Loop
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linebaker" wrote in message
.. .
Hi everybody,

I don't know how to compare 2 cells. If I refered to a cell, like A1 and
compare it to D1, how I must write the line because my loop will always
referd to A1. I have the same problem when I want to insert a partial

row,
it will be always at D1:G1.

Sub Macro1()
Range("a1").Activate
Do until ActiveCell.Value <0.01
'Cell A1 = cell D1?
If Range("a1") = Range("d1") Then
'Cell B1 = cell E1?
If Range("b1") = Range("e1") Then
'Cell C1 = cell F1?
If Range("c1") = Range("f1") Then
'Return to A2
ActiveCell.Offset(1, 0).Select
End If
End If
Else: Range(d1:g1).Activate
'Insert a partial row at D1:G1 to move date
Selection.Insert Shift:=xlDown
'Go to G1 and write Change
ActiveCell.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = "Change"
End If
Loop
End Sub

Thanks for your help






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Newbie's question.

Is this what you want

Sub Macro2()
Dim i As Long

With Range("a1")
Do Until ActiveCell.Value < 0.01
'Cell A1 = cell D1?
If .Offset(i, 0) = .Offset(i, 3) Then
'Cell B1 = cell E1?
If .Offset(i, 1) = .Offset(i, 4) Then
'Cell C1 = cell F1?
If .Offset(i, 2) = .Offset(i, 5) Then
'Return to A2
End If
End If
Else
.Range(Cells(i + 1, 1), Cells(i + 1, 7)).Insert
Shift:=xlDown
'Go to G1 and write Change
.Offset(i - 1, 6).Value = "Change"
End If
i = i + 1
Loop
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linebaker" wrote in message
. ..
Hi Bob,

I tried it but when A1 < D1 it jump to the end sub and didn't insert the
word "Change" in G1. How to do this.

Thanks very much Bob for your help.

"Bob Phillips" a écrit dans le message
de ...
Is this what you want

Sub Macro1()
Dim i As Long

With Range("a1")
Do Until ActiveCell.Value < 0.01
'Cell A1 = cell D1?
If .Offset(i, 0) = .Offset(i, 3) Then
'Cell B1 = cell E1?
If .Offset(i, 1) = .Offset(i, 4) Then
'Cell C1 = cell F1?
If .Offset(i, 2) = .Offset(i, 5) Then
'Return to A2
End If
End If
Else
.Range(Cells(i + 1, 1), Cells(i + 1, 7)).Insert
Shift:=xlDown
'Go to G1 and write Change
.Offset(i, 6).Value = "Change"
End If
i = i + 1
Loop
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linebaker" wrote in message
.. .
Hi everybody,

I don't know how to compare 2 cells. If I refered to a cell, like A1

and
compare it to D1, how I must write the line because my loop will

always
referd to A1. I have the same problem when I want to insert a partial

row,
it will be always at D1:G1.

Sub Macro1()
Range("a1").Activate
Do until ActiveCell.Value <0.01
'Cell A1 = cell D1?
If Range("a1") = Range("d1") Then
'Cell B1 = cell E1?
If Range("b1") = Range("e1") Then
'Cell C1 = cell F1?
If Range("c1") = Range("f1") Then
'Return to A2
ActiveCell.Offset(1, 0).Select
End If
End If
Else: Range(d1:g1).Activate
'Insert a partial row at D1:G1 to move date
Selection.Insert Shift:=xlDown
'Go to G1 and write Change
ActiveCell.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = "Change"
End If
Loop
End Sub

Thanks for your help








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Newbie's question.

My data in B2 < E2 are differents and are read like B2 = D2. Why?

Thanks again.

"Bob Phillips" a écrit dans le message
de ...
Is this what you want

Sub Macro2()
Dim i As Long

With Range("a1")
Do Until ActiveCell.Value < 0.01
'Cell A1 = cell D1?
If .Offset(i, 0) = .Offset(i, 3) Then
'Cell B1 = cell E1?
If .Offset(i, 1) = .Offset(i, 4) Then
'Cell C1 = cell F1?
If .Offset(i, 2) = .Offset(i, 5) Then
'Return to A2
End If
End If
Else
.Range(Cells(i + 1, 1), Cells(i + 1, 7)).Insert
Shift:=xlDown
'Go to G1 and write Change
.Offset(i - 1, 6).Value = "Change"
End If
i = i + 1
Loop
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linebaker" wrote in message
. ..
Hi Bob,

I tried it but when A1 < D1 it jump to the end sub and didn't insert

the
word "Change" in G1. How to do this.

Thanks very much Bob for your help.

"Bob Phillips" a écrit dans le

message
de ...
Is this what you want

Sub Macro1()
Dim i As Long

With Range("a1")
Do Until ActiveCell.Value < 0.01
'Cell A1 = cell D1?
If .Offset(i, 0) = .Offset(i, 3) Then
'Cell B1 = cell E1?
If .Offset(i, 1) = .Offset(i, 4) Then
'Cell C1 = cell F1?
If .Offset(i, 2) = .Offset(i, 5) Then
'Return to A2
End If
End If
Else
.Range(Cells(i + 1, 1), Cells(i + 1, 7)).Insert
Shift:=xlDown
'Go to G1 and write Change
.Offset(i, 6).Value = "Change"
End If
i = i + 1
Loop
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linebaker" wrote in message
.. .
Hi everybody,

I don't know how to compare 2 cells. If I refered to a cell, like A1

and
compare it to D1, how I must write the line because my loop will

always
referd to A1. I have the same problem when I want to insert a

partial
row,
it will be always at D1:G1.

Sub Macro1()
Range("a1").Activate
Do until ActiveCell.Value <0.01
'Cell A1 = cell D1?
If Range("a1") = Range("d1") Then
'Cell B1 = cell E1?
If Range("b1") = Range("e1") Then
'Cell C1 = cell F1?
If Range("c1") = Range("f1") Then
'Return to A2
ActiveCell.Offset(1, 0).Select
End If
End If
Else: Range(d1:g1).Activate
'Insert a partial row at D1:G1 to move date
Selection.Insert Shift:=xlDown
'Go to G1 and write Change
ActiveCell.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = "Change"
End If
Loop
End Sub

Thanks for your help










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
Newbie's macro doesn't appear to work! evillen Excel Programming 2 October 9th 03 01:07 PM


All times are GMT +1. The time now is 01:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"