Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA question involving an InputBox

I was wondering if anyone knew the syntax for this:

I have a worksheet macro that senses when a cell value is "FAIL". It
then prompts the user with an input box, and sends that result to
another cell at the end of that row. I'm having trouble with writing
the result of the input box to another cell.

Can this be done with ranges...? I've yet to get the syntax right.

Here's what I have so far:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("K2:S212")) Is Nothing Then
If Target.Value = "FAIL" Then
Dim varUserInput As Variant
varUserInput = InputBox("Enter comments: ", _
"Comment Field", "")
If varUserInput < "" Then

'here's where I need to write varUserInput to a cell at
' the end of the current row



End If
End If
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default VBA question involving an InputBox

You don't say what you mean by the "end of the row", so
I'll assume that since you're checking range K2:S2 that
the reply goes in column T

cells(Target.row,"T").Value = varUserInput

Note that this will fire the change event once more, but
as T is out of the range, the input box isn't used!

TIP:
One could always turn off events for this type of
functionality if required
eg

Application.EnableEvents = False
cells(target.row,"T").Value = varUserInput
Application.EnableEvents = True


This isn't really necessary for the question as defined
though it's worth keeoping in mind


Patrick Molloy
Microsoft Excel MVP
-------------------
I Feel Great

-----Original Message-----
I was wondering if anyone knew the syntax for this:

I have a worksheet macro that senses when a cell value

is "FAIL". It
then prompts the user with an input box, and sends that

result to
another cell at the end of that row. I'm having trouble

with writing
the result of the input box to another cell.

Can this be done with ranges...? I've yet to get the

syntax right.

Here's what I have so far:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("K2:S212"))

Is Nothing Then
If Target.Value = "FAIL" Then
Dim varUserInput As Variant
varUserInput = InputBox("Enter comments: ", _
"Comment Field", "")
If varUserInput < "" Then

'here's where I need to write varUserInput to a

cell at
' the end of the current row



End If
End If
End If
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
A question involving attaching formulas Dries New Users to Excel 2 March 14th 06 02:20 PM
A question involving attaching formulas Dries New Users to Excel 5 March 10th 06 05:49 PM
A question involving attaching formulas Dries New Users to Excel 1 March 10th 06 03:45 PM
VBA question involving an InputBox Don Lindros Excel Programming 3 April 12th 04 04:57 PM
VBA question involving numerous additions MASON Excel Programming 4 December 31st 03 03:24 AM


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