ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable in Macro? (https://www.excelbanter.com/excel-programming/367743-variable-macro.html)

JVLennox[_9_]

Variable in Macro?
 

Hi everybody,

this is probably not the most challenging question for you, but still
don't know how to do it (Newbie).

I have a little Macro, that counts lines with certain Elements in
logfile:

Code
-------------------
Sub LogDateiLesen()
Dim zeile, anz ' zeile means line
Open "C:\Log.txt" For Input As 1
While Not EOF(1)
Line Input #1, zeile
If InStr(zeile, "ELEMENT") 0 And InStr(zeile, "pubid-601311277") 0 Then anz = anz + 1
Wend
Close
Cells(5, 4) = anz 'cell D5
End Su
-------------------


Now, instead of ELEMENT as one of the criteria above, I would like t
have the _content_of_the_cell_A3__of the active worksheet as
criteria.
PLUS this content shall be followed by an additional space.
So I guess I have to define a variable....?
How do I have to put it into that code??

THANKS SO MUCH!!!

JVLenno

--
JVLenno
-----------------------------------------------------------------------
JVLennox's Profile: http://www.excelforum.com/member.php...fo&userid=3250
View this thread: http://www.excelforum.com/showthread.php?threadid=56307


Don Guillett

Variable in Macro?
 
not tested but try

InStr(zeile, "ELEMENT")

InStr(zeile, range("a1") & " ")
--
Don Guillett
SalesAid Software

"JVLennox" wrote in
message ...

Hi everybody,

this is probably not the most challenging question for you, but still I
don't know how to do it (Newbie).

I have a little Macro, that counts lines with certain Elements in a
logfile:

Code:
--------------------
Sub LogDateiLesen()
Dim zeile, anz ' zeile means line
Open "C:\Log.txt" For Input As 1
While Not EOF(1)
Line Input #1, zeile
If InStr(zeile, "ELEMENT") 0 And InStr(zeile, "pubid-601311277") 0
Then anz = anz + 1
Wend
Close
Cells(5, 4) = anz 'cell D5
End Sub
--------------------


Now, instead of ELEMENT as one of the criteria above, I would like to
have the _content_of_the_cell_A3__of the active worksheet as a
criteria.
PLUS this content shall be followed by an additional space.
So I guess I have to define a variable....?
How do I have to put it into that code??

THANKS SO MUCH!!!

JVLennox


--
JVLennox
------------------------------------------------------------------------
JVLennox's Profile:
http://www.excelforum.com/member.php...o&userid=32505
View this thread: http://www.excelforum.com/showthread...hreadid=563078





All times are GMT +1. The time now is 05:35 PM.

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