ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Storing textin a variable and comparing to a second value (https://www.excelbanter.com/excel-discussion-misc-queries/230622-storing-textin-variable-comparing-second-value.html)

Ron

Storing textin a variable and comparing to a second value
 
Not sure if I'm going about this right.
I need to go compare text (a name) in a cell with text (a name) in another
cell.

After that I do some stuff, which I should be able to handle. I just can't
figure the VBA syntax to do that. It will be part of a larger macro.

New to VBA and can't seem to find a web site that helps.

Ron

FSt1

Storing textin a variable and comparing to a second value
 
hi
a little sketchy on details but
try this..
Sub Matchit()
If Range("A2").Value = Range("C2").Value Then
MsgBox "match"
Else
MsgBox "no match"
End If
End Sub

regards
FSt1

"Ron" wrote:

Not sure if I'm going about this right.
I need to go compare text (a name) in a cell with text (a name) in another
cell.

After that I do some stuff, which I should be able to handle. I just can't
figure the VBA syntax to do that. It will be part of a larger macro.

New to VBA and can't seem to find a web site that helps.

Ron


Ron

Storing textin a variable and comparing to a second value
 
Thanks very much. It was the
If Range("A2").Value = Range("C2").Value Then
syntax I couldn't figure out.

Ron

"FSt1" wrote:

hi
a little sketchy on details but
try this..
Sub Matchit()
If Range("A2").Value = Range("C2").Value Then
MsgBox "match"
Else
MsgBox "no match"
End If
End Sub

regards
FSt1

"Ron" wrote:

Not sure if I'm going about this right.
I need to go compare text (a name) in a cell with text (a name) in another
cell.

After that I do some stuff, which I should be able to handle. I just can't
figure the VBA syntax to do that. It will be part of a larger macro.

New to VBA and can't seem to find a web site that helps.

Ron


Ron

Storing textin a variable and comparing to a second value
 
Ok, ok, I'm stuck again. The test worked, but after the test, I need to
increment both A2 and C2 by 8 and run it again. (a10 & c10)

I can't figure out how to store it and then increment it. If I use
relatives and offset, how do I compare the two cells again?

Sub Matchit()
If Range("A2").Value = Range("C2").Value Then
Increment a2 to a10 and c2 to c10 and run it again.
Else
Insert 8 blank lines, moving c2 down to c10 and test again. (I think I
can do this as I did it in a macro)
End If
End Sub

Thanks for the help.

Ron

"Ron" wrote:

Thanks very much. It was the
If Range("A2").Value = Range("C2").Value Then
syntax I couldn't figure out.

Ron

"FSt1" wrote:

hi
a little sketchy on details but
try this..
Sub Matchit()
If Range("A2").Value = Range("C2").Value Then
MsgBox "match"
Else
MsgBox "no match"
End If
End Sub

regards
FSt1

"Ron" wrote:

Not sure if I'm going about this right.
I need to go compare text (a name) in a cell with text (a name) in another
cell.

After that I do some stuff, which I should be able to handle. I just can't
figure the VBA syntax to do that. It will be part of a larger macro.

New to VBA and can't seem to find a web site that helps.

Ron



All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com