Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Looping through a specific column

Hi,

I want to be able to loop through column B and search for a value that is
stored in a text box (txtCriteria1) on my userform. If the value is found in
column B, display message saying 'exists', else, display a message that says
'does not exist'.

Can anyone help?


--
Carlee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Looping through a specific column

Hi Carlee,

One way:

'=============
Private Sub CommandButton1_Click()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim sStr As String
Dim msg As String

Set WB = ThisWorkbook
Set SH = WB.Sheets("Sheet1")
Set Rng = SH.Columns("B:B")
sStr = Me.txtCriteria1.Value

If Application.CountIf(Rng, sStr) Then
msg = sStr & " found"
Else
msg = sStr & " not found"
End If

MsgBox Prompt:=msg

End Sub
'<<=============

---
Regards,
Norman


"Carlee" wrote in message
...
Hi,

I want to be able to loop through column B and search for a value that is
stored in a text box (txtCriteria1) on my userform. If the value is found
in
column B, display message saying 'exists', else, display a message that
says
'does not exist'.

Can anyone help?


--
Carlee



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
VBA column identifier and looping Robert Excel Programming 2 May 15th 06 02:44 PM
Looping through a column hudson40 Excel Programming 1 August 16th 05 03:31 PM
looping through specific worksheets simora Excel Programming 0 May 29th 05 12:36 AM
Please help...I need a looping macro at a specific time Ed[_9_] Excel Programming 0 April 14th 04 05:24 PM
looping from one column to the next Brad Zenner Excel Programming 0 July 21st 03 08:41 PM


All times are GMT +1. The time now is 07:48 PM.

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"