View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Michael168[_29_] Michael168[_29_] is offline
external usenet poster
 
Posts: 1
Default How to count in between gap?

merjet wrote:
* Is it possible to use input box insteading of definining
everything
inside the module itself, so that it will be more friendly user.


Sub macro1()
Dim str1 As String
Dim str2 As String
Dim c As Range
Dim rng As Range
Dim iCt As Integer

str1 = InputBox("What do you want to search for?")
str2 = InputBox("In what range, e.g. A1:A10?")
Set rng = ActiveSheet.Range(str2)
For Each c In rng
If c = str1 Then
iCt = iCt + 1
If iCt = 1 Then ActiveSheet.Cells(1, 3) = str1
ActiveSheet.Cells(1, 3 + iCt) = c.Row
End If
Next c

End Sub


HTH,
Merjet *


I need to check more than one cell conditions, lets say 3 cells value
then what should I do ?

Thanks
Michael168



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/