Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default variable/Input box problem

Hi i have a program that takes information from inputboxes. The user
enters the info in and it adds it to a list within the spreadsheet.
The info entered can be text or numerical. When the user enters the
info the program looks to see if they have already entered that info
onto the list.

If the user adds text it checks the list and returns a message if they
have already entered that text. But when i enter a number that i have
already entered then it still allow me to input it onto the list. I
have tried declaring the variable assigned to the input box as an
integer but get an integer, it then checks the numbers entered ok, but
throws out an error if i eneter a text value. here the bit of code i
am using. any help greatly recieved.

Sub ADDMAN()
Dim clear
Dim JOBCHECK

'this bit makes sure the users enters something'
Do While clear = ""
clear = InputBox("Please enter A1024/D-Pole Ref")
Loop

'this bit checks the info has not already been entered'
JOBCHECK = 0
Sheets("WORKLIST").Select
Range("A1").Select
Do While Selection.Value < ""
ActiveCell.Offset(1, 0).Select
If ActiveCell = clear Then JOBCHECK = 1
Loop

If JOBCHECK = 1 Then MsgBox Title:="POLETRACKER", PROMPT:="SORRY THIS
JOB ALREADY EXISTS ON YOUR CURRENT WORKSTACK!"
If JOBCHECK = 1 Then Sheets("MENU").Select
If JOBCHECK = 1 Then exit sub

'THIS BIT ENTERS THE VALUE TO THE LIST'
Sheets("WORKLIST").Select
Range("A1").Select
Do While Selection.Value < ""
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell = clear


END SUB

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default variable/Input box problem

If lcase(Trim(ActiveCell.Text)) = lcase(Trim(cStr(clear))) Then JOBCHECK = 1


--
Regards.
Tom Ogilvy


wrote in message
ups.com...
Hi i have a program that takes information from inputboxes. The user
enters the info in and it adds it to a list within the spreadsheet.
The info entered can be text or numerical. When the user enters the
info the program looks to see if they have already entered that info
onto the list.

If the user adds text it checks the list and returns a message if they
have already entered that text. But when i enter a number that i have
already entered then it still allow me to input it onto the list. I
have tried declaring the variable assigned to the input box as an
integer but get an integer, it then checks the numbers entered ok, but
throws out an error if i eneter a text value. here the bit of code i
am using. any help greatly recieved.

Sub ADDMAN()
Dim clear
Dim JOBCHECK

'this bit makes sure the users enters something'
Do While clear = ""
clear = InputBox("Please enter A1024/D-Pole Ref")
Loop

'this bit checks the info has not already been entered'
JOBCHECK = 0
Sheets("WORKLIST").Select
Range("A1").Select
Do While Selection.Value < ""
ActiveCell.Offset(1, 0).Select
If ActiveCell = clear Then JOBCHECK = 1
Loop

If JOBCHECK = 1 Then MsgBox Title:="POLETRACKER", PROMPT:="SORRY THIS
JOB ALREADY EXISTS ON YOUR CURRENT WORKSTACK!"
If JOBCHECK = 1 Then Sheets("MENU").Select
If JOBCHECK = 1 Then exit sub

'THIS BIT ENTERS THE VALUE TO THE LIST'
Sheets("WORKLIST").Select
Range("A1").Select
Do While Selection.Value < ""
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell = clear


END SUB



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default variable/Input box problem

John,

Change

If ActiveCell = clear Then JOBCHECK = 1

to

If ActiveCell = CStr(clear) Then JOBCHECK = 1

But, there isn't any need for all that looping. See the example below,
which also has better entry checking and loops back to the beginning if the
entry was already found.

HTH,
Bernie
MS Excel MVP

Sub AddMan()
Dim strClear As String

GetEntry:
strClear = ""

'this bit makes sure the users enters something'
Do While strClear = ""
strClear = Application.InputBox("Please enter A1024/D-Pole Ref")
If strClear = "False" Then Exit Sub ' User hit cancel
Loop

'this bit checks the info has not already been entered'
If Application.CountIf(Sheets("WORKLIST").Range("A:A" ), _
strClear) = 0 Then
Range("A65536").End(xlUp)(2).Value = strClear
Else
MsgBox "Sorry, job already in the workstack.", _
vbOKOnly, "PoleTracker"
Sheets("MENU").Select
GoTo GetEntry
End If

End Sub




wrote in message
ups.com...
Hi i have a program that takes information from inputboxes. The user
enters the info in and it adds it to a list within the spreadsheet.
The info entered can be text or numerical. When the user enters the
info the program looks to see if they have already entered that info
onto the list.

If the user adds text it checks the list and returns a message if they
have already entered that text. But when i enter a number that i have
already entered then it still allow me to input it onto the list. I
have tried declaring the variable assigned to the input box as an
integer but get an integer, it then checks the numbers entered ok, but
throws out an error if i eneter a text value. here the bit of code i
am using. any help greatly recieved.

Sub ADDMAN()
Dim clear
Dim JOBCHECK

'this bit makes sure the users enters something'
Do While clear = ""
clear = InputBox("Please enter A1024/D-Pole Ref")
Loop

'this bit checks the info has not already been entered'
JOBCHECK = 0
Sheets("WORKLIST").Select
Range("A1").Select
Do While Selection.Value < ""
ActiveCell.Offset(1, 0).Select
If ActiveCell = clear Then JOBCHECK = 1
Loop

If JOBCHECK = 1 Then MsgBox Title:="POLETRACKER", PROMPT:="SORRY THIS
JOB ALREADY EXISTS ON YOUR CURRENT WORKSTACK!"
If JOBCHECK = 1 Then Sheets("MENU").Select
If JOBCHECK = 1 Then exit sub

'THIS BIT ENTERS THE VALUE TO THE LIST'
Sheets("WORKLIST").Select
Range("A1").Select
Do While Selection.Value < ""
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell = clear


END SUB



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
Variable sum from defined input David Excel Worksheet Functions 7 March 10th 09 06:26 AM
With QUERY how to input a variable Guillaume Excel Discussion (Misc queries) 1 December 8th 05 02:28 PM
Formulas containing variable input ym4life Excel Discussion (Misc queries) 5 August 16th 05 01:07 PM
Input box with variable buggy Excel Programming 2 November 19th 04 03:11 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


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