Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Pull Down Menu - Code not working

I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Pull Down Menu - Code not working

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Pull Down Menu - Code not working

Hi, this does help but I also need it to populate each row beneath the pull
down menu, that's why I thought I needed the "+1" string. How do I add that
to it?

Thanks again!

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Pull Down Menu - Code not working

Laura,

The line

Target.Offset(1, 0).Value = myVal

does just that - it fills in the row below the cell with the pulldown.

(Though it would be just as easy to fill in that cell directly...)

So, I'm not sure what you want besides that...

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi, this does help but I also need it to populate each row beneath the pull
down menu, that's why I thought I needed the "+1" string. How do I add that
to it?

Thanks again!

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Pull Down Menu - Code not working

Hi Bernie,
How do you get it to populate cells beneath the pull down? Not just the cell
below it? (one at a time)

Laura

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Pull Down Menu - Code not working

Hi Bernie,
If the pull down menu is in G3, I need to be able to use the pull down for
all the cells below G3, not just G4.... is it possible?

"Bernie Deitrick" wrote:

Laura,

The line

Target.Offset(1, 0).Value = myVal

does just that - it fills in the row below the cell with the pulldown.

(Though it would be just as easy to fill in that cell directly...)

So, I'm not sure what you want besides that...

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi, this does help but I also need it to populate each row beneath the pull
down menu, that's why I thought I needed the "+1" string. How do I add that
to it?

Thanks again!

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Pull Down Menu - Code not working

Laura,

Try

Cells(Rows.Count, 7).End(xlUp)(2).Value = myVal

to fill in the first empty cell below G3 (G4, then G5, then G6, etc.)

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi Bernie,
If the pull down menu is in G3, I need to be able to use the pull down for
all the cells below G3, not just G4.... is it possible?

"Bernie Deitrick" wrote:

Laura,

The line

Target.Offset(1, 0).Value = myVal

does just that - it fills in the row below the cell with the pulldown.

(Though it would be just as easy to fill in that cell directly...)

So, I'm not sure what you want besides that...

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi, this does help but I also need it to populate each row beneath the pull
down menu, that's why I thought I needed the "+1" string. How do I add that
to it?

Thanks again!

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Pull Down Menu - Code not working

THANK YOU!!!!!!

"Bernie Deitrick" wrote:

Laura,

Try

Cells(Rows.Count, 7).End(xlUp)(2).Value = myVal

to fill in the first empty cell below G3 (G4, then G5, then G6, etc.)

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi Bernie,
If the pull down menu is in G3, I need to be able to use the pull down for
all the cells below G3, not just G4.... is it possible?

"Bernie Deitrick" wrote:

Laura,

The line

Target.Offset(1, 0).Value = myVal

does just that - it fills in the row below the cell with the pulldown.

(Though it would be just as easy to fill in that cell directly...)

So, I'm not sure what you want besides that...

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi, this does help but I also need it to populate each row beneath the pull
down menu, that's why I thought I needed the "+1" string. How do I add that
to it?

Thanks again!

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

End Sub









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Pull Down Menu - Code not working

THANK YOU!!!!!! Awesome!

"Bernie Deitrick" wrote:

Laura,

Try

Cells(Rows.Count, 7).End(xlUp)(2).Value = myVal

to fill in the first empty cell below G3 (G4, then G5, then G6, etc.)

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi Bernie,
If the pull down menu is in G3, I need to be able to use the pull down for
all the cells below G3, not just G4.... is it possible?

"Bernie Deitrick" wrote:

Laura,

The line

Target.Offset(1, 0).Value = myVal

does just that - it fills in the row below the cell with the pulldown.

(Though it would be just as easy to fill in that cell directly...)

So, I'm not sure what you want besides that...

HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
Hi, this does help but I also need it to populate each row beneath the pull
down menu, that's why I thought I needed the "+1" string. How do I add that
to it?

Thanks again!

"Bernie Deitrick" wrote:

Laura,

I tried to code what your words were describing, not what your code was seeming to do...


Private Sub Worksheet_Change(ByVal Target As Range)

Dim myVal As Variant

If Target.Value = "" Then Exit Sub
If Target.Column < 7 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, _
Cells.SpecialCells(xlCellTypeAllValidation)) _
Is Nothing Then Exit Sub

myVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Offset(1, 0).Value = myVal
Application.EnableEvents = True

End Sub


HTH,
Bernie
MS Excel MVP


"Laura L" wrote in message
...
I'm trying to modify the code below so that 1) when using the pull down menu,
it populates the cell below it , and 2) it only applies to one column. Right
now, when you use the pull down menu it just populates that same cell, not
the one below it. Any help is greatly appreciated.

Thanks,
Laura

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long

lCol = Target.Column 'column with data validation cell

If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
If Target.Value = "" Then GoTo exitHandler
Application.EnableEvents = False
Select Case Target.Column
Case 7
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol).End(xlUp).Row + 1
End If
Cells(lRow, lCol).Value = Target.Value
End Select

End If

exitHandler:
Application.EnableEvents = True

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
Help w/ modifying code... pull down menu Laura L[_2_] Excel Programming 2 April 30th 07 05:40 PM
Excel pull down menu kwf Excel Worksheet Functions 0 March 9th 06 04:17 PM
Pull Down Menu Bar JB in Kansas Excel Discussion (Misc queries) 2 May 30th 05 02:20 PM
Select pull down menu majikman Excel Programming 2 May 6th 04 04:14 PM
pull down menu ben Excel Programming 3 February 2nd 04 08:12 PM


All times are GMT +1. The time now is 02:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"