Simple input box problem

paulsolar

Well-known Member
Joined
Aug 21, 2013
Messages
682
Office Version
  1. 365
Hi All

i very rarely ever use an input box so I'm not very good at them

I am trying to use one to enter just a number in a cell, it's entering the number in the cell but then causing an error, the error debugs back "If Intersect(Target, Range("B3")) = "Standard pontoon berth per metre" Then"

It's Friday afternoon and I'm running out of time and temperament, my lap top is about to get thrown through a window, closely followed by what is now left of my hair having torn most of it out with frustration :)

Any help would be greatly appreciated

Cheers

Paul

VBA Code:
Private Sub worksheet_change(ByVal Target As Range)

If Intersect(Target, Range("B3")) = "Standard pontoon berth per metre" Then

Range("F2").Value = InputBox("Enter boat length in metres.", "Boat length")

End If

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
What exactly are you attempting to do here?
VBA Code:
If Intersect(Target, Range("B3")) = "Standard pontoon berth per metre" Then

You use INTERSECT to see if your two ranges overlap. It simply returns TRUE or FALSE.
To set them equal to something makes no sense.

Perhaps this is what you want?
VBA Code:
Private Sub worksheet_change(ByVal Target As Range)

If Not (Intersect(Target, Range("B3")) is Nothing) Then
    If Range("B3") = "Standard pontoon berth per metre" Then
        Range("F2").Value = InputBox("Enter boat length in metres.", "Boat length")
    End If
End If

End Sub
If that does not do what you want, please explain exactly how you want this to work, in plain English.
 
Upvote 0
Solution
Many Thanks Joe, that was a quick reply and worked perfectly.

I just copied a bit of code I'd written before, i never looked at the sub title. I'm getting to old for this now.

have a lovely weekend

cheers

Paul
 
Upvote 0
You are welcome.

Have a good weekend too!
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top