Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Count all VLOOKUP() functions on worksheet


How can I count all the VLOOKUP() functions on an active worksheet usin
VBA?

Thank you very much for the help

--
golzill
-----------------------------------------------------------------------
golzilla's Profile: http://www.excelforum.com/member.php...fo&userid=1678
View this thread: http://www.excelforum.com/showthread.php?threadid=31986

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Count all VLOOKUP() functions on worksheet

Hi Golzill,
This assumes there is at least two instances of a Vlookup. Z is the counter
and it will start out in "A1" and look forward from there. It starts out with
Z set to 0, but it will go through the loop and end up at the first "Find"
and count it again.

Sub Macro1()
Range("A1").Select
Cells.Find(What:="=VLOOKUP", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
StartAddress = ActiveCell.Address
Z = 0
Do
Cells.FindNext(After:=ActiveCell).Activate
Z = Z + 1
Loop While ActiveCell.Address < StartAddress
End Sub


"golzilla" wrote:


How can I count all the VLOOKUP() functions on an active worksheet using
VBA?

Thank you very much for the help!


--
golzilla
------------------------------------------------------------------------
golzilla's Profile: http://www.excelforum.com/member.php...o&userid=16789
View this thread: http://www.excelforum.com/showthread...hreadid=319863


  #3   Report Post  
Posted to microsoft.public.excel.programming
J_J J_J is offline
external usenet poster
 
Posts: 58
Default Count all VLOOKUP() functions on worksheet

Hi David,
I find out with your code that
SearchFormat:=
is not recognized with XL2K
any suggestions?
TIA

"David" wrote in message
...
Hi Golzill,
This assumes there is at least two instances of a Vlookup. Z is the

counter
and it will start out in "A1" and look forward from there. It starts out

with
Z set to 0, but it will go through the loop and end up at the first "Find"
and count it again.

Sub Macro1()
Range("A1").Select
Cells.Find(What:="=VLOOKUP", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
StartAddress = ActiveCell.Address
Z = 0
Do
Cells.FindNext(After:=ActiveCell).Activate
Z = Z + 1
Loop While ActiveCell.Address < StartAddress
End Sub


"golzilla" wrote:


How can I count all the VLOOKUP() functions on an active worksheet using
VBA?

Thank you very much for the help!


--
golzilla
------------------------------------------------------------------------
golzilla's Profile:

http://www.excelforum.com/member.php...o&userid=16789
View this thread:

http://www.excelforum.com/showthread...hreadid=319863




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Count all VLOOKUP() functions on worksheet

Remove that portion from the code.

J_J wrote:

Hi David,
I find out with your code that
SearchFormat:=
is not recognized with XL2K
any suggestions?
TIA

"David" wrote in message
...
Hi Golzill,
This assumes there is at least two instances of a Vlookup. Z is the

counter
and it will start out in "A1" and look forward from there. It starts out

with
Z set to 0, but it will go through the loop and end up at the first "Find"
and count it again.

Sub Macro1()
Range("A1").Select
Cells.Find(What:="=VLOOKUP", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
StartAddress = ActiveCell.Address
Z = 0
Do
Cells.FindNext(After:=ActiveCell).Activate
Z = Z + 1
Loop While ActiveCell.Address < StartAddress
End Sub


"golzilla" wrote:


How can I count all the VLOOKUP() functions on an active worksheet using
VBA?

Thank you very much for the help!


--
golzilla
------------------------------------------------------------------------
golzilla's Profile:

http://www.excelforum.com/member.php...o&userid=16789
View this thread:

http://www.excelforum.com/showthread...hreadid=319863



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
J_J J_J is offline
external usenet poster
 
Posts: 58
Default Count all VLOOKUP() functions on worksheet

Thanks Dave. But how do I get the number of cells containing VLOOKUP fomulas
displayed?. The below code fails to display the value Z

Private Sub CommandButton1_Click()
Dim A As Variant
Macro1 ' macro doing the counting
A = Z ' assign the loop value to A
MsgBox ("The number of cells containig VLOOKUP formula is " & A)
End Sub



"Dave Peterson" wrote in message
...
Remove that portion from the code.

J_J wrote:

Hi David,
I find out with your code that
SearchFormat:=
is not recognized with XL2K
any suggestions?
TIA

"David" wrote in message
...
Hi Golzill,
This assumes there is at least two instances of a Vlookup. Z is the

counter
and it will start out in "A1" and look forward from there. It starts

out
with
Z set to 0, but it will go through the loop and end up at the first

"Find"
and count it again.

Sub Macro1()
Range("A1").Select
Cells.Find(What:="=VLOOKUP", After:=ActiveCell, LookIn:=xlFormulas,

_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
StartAddress = ActiveCell.Address
Z = 0
Do
Cells.FindNext(After:=ActiveCell).Activate
Z = Z + 1
Loop While ActiveCell.Address < StartAddress
End Sub


"golzilla" wrote:


How can I count all the VLOOKUP() functions on an active worksheet

using
VBA?

Thank you very much for the help!


--
golzilla

------------------------------------------------------------------------
golzilla's Profile:

http://www.excelforum.com/member.php...o&userid=16789
View this thread:

http://www.excelforum.com/showthread...hreadid=319863



--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Count all VLOOKUP() functions on worksheet

You could convert that suggested code into a function and have a value returned,
or just plop the code into you commandbutton's code:

Option Explicit
Sub CommandButton1_Click()

Dim FoundCell As Range
Dim vlookupCtr As Long
Dim FirstAddress

ActiveCell.Activate

With ActiveSheet
With .Cells

Set FoundCell = .Find("=vlookup(", after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlPart, _
searchOrder:=xlByRows, SearchDirection:=xlNext,
_
MatchCase:=False)
If FoundCell Is Nothing Then
'do nothing
Else
FirstAddress = FoundCell.Address
Do
vlookupCtr = vlookupCtr + 1
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress

End If
End With
End With

MsgBox vlookupCtr

End Sub






J_J wrote:

Thanks Dave. But how do I get the number of cells containing VLOOKUP fomulas
displayed?. The below code fails to display the value Z

Private Sub CommandButton1_Click()
Dim A As Variant
Macro1 ' macro doing the counting
A = Z ' assign the loop value to A
MsgBox ("The number of cells containig VLOOKUP formula is " & A)
End Sub

"Dave Peterson" wrote in message
...
Remove that portion from the code.

J_J wrote:

Hi David,
I find out with your code that
SearchFormat:=
is not recognized with XL2K
any suggestions?
TIA

"David" wrote in message
...
Hi Golzill,
This assumes there is at least two instances of a Vlookup. Z is the
counter
and it will start out in "A1" and look forward from there. It starts

out
with
Z set to 0, but it will go through the loop and end up at the first

"Find"
and count it again.

Sub Macro1()
Range("A1").Select
Cells.Find(What:="=VLOOKUP", After:=ActiveCell, LookIn:=xlFormulas,

_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
StartAddress = ActiveCell.Address
Z = 0
Do
Cells.FindNext(After:=ActiveCell).Activate
Z = Z + 1
Loop While ActiveCell.Address < StartAddress
End Sub


"golzilla" wrote:


How can I count all the VLOOKUP() functions on an active worksheet

using
VBA?

Thank you very much for the help!


--
golzilla

------------------------------------------------------------------------
golzilla's Profile:
http://www.excelforum.com/member.php...o&userid=16789
View this thread:
http://www.excelforum.com/showthread...hreadid=319863



--

Dave Peterson


--

Dave Peterson
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
Count functions Jalal Excel Worksheet Functions 4 April 15th 09 08:51 AM
Count Functions Robin W Excel Discussion (Misc queries) 4 October 22nd 08 07:23 PM
Count Functions TSNS Excel Worksheet Functions 34 October 20th 07 05:04 PM
Fun with COUNT and AND functions. Johosh Excel Worksheet Functions 8 October 2nd 07 07:25 PM
functions to count Yes & No fofo Excel Worksheet Functions 4 June 13th 06 11:00 PM


All times are GMT +1. The time now is 08:14 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"