Clearing Active Cell

Beck123

New Member
Joined
Apr 26, 2011
Messages
3
Hi all,

For some cells I can select value from Listbox, but for some cells I have to enter values manuelly.

If value from Listbox is choosen Inputbox pops up. One can either enter value or "Cancel" the action.After clicking "Cancel" chosen value from Listbox gets cleared. Now it is working.

After entering value manuelly into Cell(eg. D48) Inputbox pops up. Here is also "OK" and "Cancel" buttons. If I "Cancel" the action manuelly entered value does not get cleared, but it clears the Cell in the next line D49.

Here is code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
Dim strProjectNr As String
Dim strProject As String
If Intersect(Target, Range("D33:D79,D86:D97")) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
Projektnummer:
strProjectNr = InputBox("Project Nr.", "Bitte Project-Nr. eingeben:")
If strProjectNr = "" Then
ActiveCell.Clear
Exit Sub
End If
Target.Offset(0, 1) = strProjectNr
Projektname:
If Intersect(Target, Range("D33:D79")) Is Nothing Then Exit Sub
strProject = InputBox("Project Name", "Bitte Project-Name eingeben:")
Target.Offset(0, 2) = strProject
End Sub


Thanks,
Beck
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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