Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Code required please

Hi. Some help with this would be appreciated......

I have a worksheet with a list of numbers in column "A".
I would like a command button on the sheet that when pressed acivates an
input box requseting the user to enter a number. When the number is entered
the code would search column "A" and if a match is found then display this
fact to the user. If no match is found then add the new number to the list
and also advise the user that this has in fact been done.

thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Code required please

How about something like:

Option Explicit

Sub FindMyNum()

Dim rng As Range
Dim NUM As Long
Dim NextCell As Range

Set NextCell = Range("A65536").End(xlUp)(2)
NUM = InputBox("ENTER A NUMBER")

Set rng = Range("A1", NextCell)
With rng
On Error Resume Next
If IsError(.Find(WHAT:=NUM, AFTER:=NextCell).Select) Then
MsgBox "Could not find your number. Will add it to the list.",
vbOKOnly, ""
NextCell = NUM
Else
MsgBox "Your number is located at: " & Selection.Address
End If
End With
End Sub


"Neal" wrote:

Hi. Some help with this would be appreciated......

I have a worksheet with a list of numbers in column "A".
I would like a command button on the sheet that when pressed acivates an
input box requseting the user to enter a number. When the number is entered
the code would search column "A" and if a match is found then display this
fact to the user. If no match is found then add the new number to the list
and also advise the user that this has in fact been done.

thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Code required please

How about something like:

Option Explicit

Sub FindMyNum()

Dim rng As Range
Dim NUM As Long
Dim NextCell As Range

Set NextCell = Range("A65536").End(xlUp)(2)
NUM = InputBox("ENTER A NUMBER")

Set rng = Range("A1", NextCell)
With rng
On Error Resume Next
If IsError(.Find(WHAT:=NUM, AFTER:=NextCell).Select) Then
MsgBox "Could not find your number. Will add it to the list.",
vbOKOnly, ""
NextCell = NUM
Else
MsgBox "Your number is located at: " & Selection.Address
End If
End With
End Sub


"Neal" wrote:

Hi. Some help with this would be appreciated......

I have a worksheet with a list of numbers in column "A".
I would like a command button on the sheet that when pressed acivates an
input box requseting the user to enter a number. When the number is entered
the code would search column "A" and if a match is found then display this
fact to the user. If no match is found then add the new number to the list
and also advise the user that this has in fact been done.

thanks in advance

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
Changes Required In Macro Code TGV Excel Discussion (Misc queries) 2 February 10th 09 05:53 PM
Another VB Code Required TGV Excel Discussion (Misc queries) 7 February 7th 09 07:21 AM
VB Code Required TGV Excel Discussion (Misc queries) 3 February 6th 09 05:31 PM
macro code required muddan madhu Excel Worksheet Functions 2 April 28th 08 03:43 PM
For....Next loop code required uplink600 Excel Programming 2 May 12th 04 04:03 PM


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