Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Input box default = last input

How can I make the default value of the input box the same as the last user
input (duplicating the functionality of the built-in find/replace dialog)?


Dim iLastRow As Long
Dim i As Long
Dim LastInput As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
Dim iLastRow As Long
Dim i As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow

If IsEmpty(Cells(i, "A")) And _
(Cells(i, "F").Value < "" Or Cells(i, "J").Value < "") Then
Cells(i, "A").Select
EnterFactory = InputBox("Enter Factory#: ")
If EnterFactory < "" Then
Cells(i, "A").Value = EnterFactory
End If
End If
Next i

End With
MsgBox "No More Blank Factories"

End Sub

Thank you so much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Input box default = last input

Use code like the following:

Dim DefaultValue As String
Dim Result As String
On Error Resume Next
DefaultValue = ThisWorkbook.Names("InputDefault").RefersTo
DefaultValue = Mid(Replace(DefaultValue, Chr(34), ""), 2)
Result = InputBox(prompt:="Enter something", Default:=DefaultValue)
If Result < vbNullString Then
ThisWorkbook.Names("InputDefault").Delete
ThisWorkbook.Names.Add Name:="InputDefault", _
RefersTo:=CStr(Result), Visible:=False
End If
On Error GoTo 0


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)



"justme" wrote in message
...
How can I make the default value of the input box the same as the last
user
input (duplicating the functionality of the built-in find/replace dialog)?


Dim iLastRow As Long
Dim i As Long
Dim LastInput As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
Dim iLastRow As Long
Dim i As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow

If IsEmpty(Cells(i, "A")) And _
(Cells(i, "F").Value < "" Or Cells(i, "J").Value < "") Then
Cells(i, "A").Select
EnterFactory = InputBox("Enter Factory#: ")
If EnterFactory < "" Then
Cells(i, "A").Value = EnterFactory
End If
End If
Next i

End With
MsgBox "No More Blank Factories"

End Sub

Thank you so much.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Input box default = last input


Hi Chip,

Thank you for answering my post. I'm not quite sure how to integrate this in
my code. Do I paste as a separate function, or within my current sub? Thanks
so much!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Input box default = last input

You would integrate it with your code, something like this:

Dim iLastRow As Long
Dim i As Long
Dim LastInput As String


With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow


With ActiveSheet

iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow

If IsEmpty(Cells(i, "A")) And _
(Cells(i, "F").Value < "" Or _
Cells(i, "J").Value < "") Then
Cells(i, "A").Select
On Error Resume Next
LastInput = ThisWorkbook.Names("InputDefault").RefersTo
LastInput = Mid(Replace(LastInput, Chr(34), ""), 2)
EnterFactory = InputBox("Enter Factory#: ", _
Default:=LastInput)
If EnterFactory < "" Then
Cells(i, "A").Value = EnterFactory
ThisWorkbook.Names("InputDefault").Delete
ThisWorkbook.Names.Add Name:="InputDefault", _
RefersTo:=CStr(EnterFactory), Visible:=False
End If
On Error goto 0
End If
Next i

End With
MsgBox "No More Blank Factories"

End Sub

--
Regards,
Tom Ogilvy

"justme" wrote in message
...

Hi Chip,

Thank you for answering my post. I'm not quite sure how to integrate this
in
my code. Do I paste as a separate function, or within my current sub?
Thanks
so much!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Input box default = last input

Thank you, Chip!
:)


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Input box default = last input

Tom,

You are my hero!

Thank you for all you do!
: ) : ) : )
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
Turning off the default date input Hanne Excel Discussion (Misc queries) 2 April 30th 08 05:16 PM
default name and value in input cell [email protected] Excel Worksheet Functions 4 November 13th 06 04:42 PM
Input Box default value as a date Dan Excel Programming 2 March 3rd 05 08:43 PM
Retaining the default in an input box - again Gordon Humphreys[_2_] Excel Programming 2 August 18th 03 02:28 PM
Retaining a default in an input box Gordon Humphreys[_2_] Excel Programming 1 August 15th 03 02:48 PM


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