Value in macro w/ multiple lines?

Sath

New Member
Joined
Aug 18, 2011
Messages
5
How do I input a cell value in a macro that has more than one line? For example:

ACTION
ACTION SPEED:4
ACTION ACCURACY:12

all these are within one cell and I want to search for cells that contain something like this. However how do I input this cell value into the macro in the cll.Value=" " area?

Thanks Guys.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
try this maybe

Code:
Sub CelVal()
CFind = "ACTION" & Chr(10) & "ACTION SPEED:4" & Chr(10) & "ACTION ACCURACY:12"
If ActiveCell.Value = CFind Then
    MsgBox "Values matched"
End If
End Sub
 
Upvote 0
Or, if you were looping through column A, looking for any cell that contains the string 'ACTION' (no matter what else it may have in there with it), then perhaps something like this:
Code:
Sub Find_ACTION_Demo()
Dim LstRw As Long, i As Range
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
For Each i In Range("A1:A" & LstRw)
  If InStr(i, "ACTION") Then MsgBox i.Value 'or whatever _
     you want it to do when your value is found
Next i
End Sub
It's hard to know which road to take without also knowing what the rest of your code is doing, but I would think one of these suggestions ought to get you squared away.

Hope it helps.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top