Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default multiple choices from pulldown... how to apply to several pulldown

Hi,
Follow up: I first added to original question, but it's really a new
question.

After using the code Debra was kind enough to share, I need to apply the
action (choose from a pull down menu and place each entry
into a new row) to 4 or 5 specific columns. I tried the following but it
didn't work.(see row surrounded by *****)
Thanks for any help.

Here's the code: (the line with all the stars is what I tried).
------
Public Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

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

********lCol = 7 or 14 or 18 or 12 'column with data validation cell****
(I also tried using "And")


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
Application.EnableEvents = False
If Target.Column = lCol Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol + 1).End(xlUp).Row + 1
End If

Cells(lRow, lCol + 1).Value = Target.Value
End If
End If

exitHandler:
Application.EnableEvents = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default multiple choices from pulldown... how to apply to several pulldown

change
If Target.Column = lCol Then

to
If Target.Column = 7 or Target.column = 12 or _
Target.column = 14 or Target.column = 18 then
Icol = Target.column

--
Regards,
Tom Ogilvy

"DianeN" wrote:

Hi,
Follow up: I first added to original question, but it's really a new
question.

After using the code Debra was kind enough to share, I need to apply the
action (choose from a pull down menu and place each entry
into a new row) to 4 or 5 specific columns. I tried the following but it
didn't work.(see row surrounded by *****)
Thanks for any help.

Here's the code: (the line with all the stars is what I tried).
------
Public Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

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

********lCol = 7 or 14 or 18 or 12 'column with data validation cell****
(I also tried using "And")


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
Application.EnableEvents = False
If Target.Column = lCol Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol + 1).End(xlUp).Row + 1
End If

Cells(lRow, lCol + 1).Value = Target.Value
End If
End If

exitHandler:
Application.EnableEvents = True

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default multiple choices from pulldown... how to apply to several pull

Hi Tom, thanks so much. I guess when I pasted the code, the "1col" and
"1row" came out looking like "I" or something... or are you saying I need
to change them from "1" to "I" ?

Sorry to be dense. When I copied and pasted your code below, it didn't give
me an error message, it just didn't work on any of the columns.
Thanks

"Tom Ogilvy" wrote:

change
If Target.Column = lCol Then

to
If Target.Column = 7 or Target.column = 12 or _
Target.column = 14 or Target.column = 18 then
Icol = Target.column

--
Regards,
Tom Ogilvy

"DianeN" wrote:

Hi,
Follow up: I first added to original question, but it's really a new
question.

After using the code Debra was kind enough to share, I need to apply the
action (choose from a pull down menu and place each entry
into a new row) to 4 or 5 specific columns. I tried the following but it
didn't work.(see row surrounded by *****)
Thanks for any help.

Here's the code: (the line with all the stars is what I tried).
------
Public Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

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

********lCol = 7 or 14 or 18 or 12 'column with data validation cell****
(I also tried using "And")


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
Application.EnableEvents = False
If Target.Column = lCol Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol + 1).End(xlUp).Row + 1
End If

Cells(lRow, lCol + 1).Value = Target.Value
End If
End If

exitHandler:
Application.EnableEvents = True

End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default multiple choices from pulldown... how to apply to several pull

Tom, nevermind. I changed the "1" to "i" on both row and column and it works!!
Thanks so much!

"DianeN" wrote:

Hi Tom, thanks so much. I guess when I pasted the code, the "1col" and
"1row" came out looking like "I" or something... or are you saying I need
to change them from "1" to "I" ?

Sorry to be dense. When I copied and pasted your code below, it didn't give
me an error message, it just didn't work on any of the columns.
Thanks

"Tom Ogilvy" wrote:

change
If Target.Column = lCol Then

to
If Target.Column = 7 or Target.column = 12 or _
Target.column = 14 or Target.column = 18 then
Icol = Target.column

--
Regards,
Tom Ogilvy

"DianeN" wrote:

Hi,
Follow up: I first added to original question, but it's really a new
question.

After using the code Debra was kind enough to share, I need to apply the
action (choose from a pull down menu and place each entry
into a new row) to 4 or 5 specific columns. I tried the following but it
didn't work.(see row surrounded by *****)
Thanks for any help.

Here's the code: (the line with all the stars is what I tried).
------
Public Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

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

********lCol = 7 or 14 or 18 or 12 'column with data validation cell****
(I also tried using "And")


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
Application.EnableEvents = False
If Target.Column = lCol Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol + 1).End(xlUp).Row + 1
End If

Cells(lRow, lCol + 1).Value = Target.Value
End If
End If

exitHandler:
Application.EnableEvents = True

End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default multiple choices from pulldown... how to apply to several pull

I wasn't suggesting that you change 1 to I, as you are correct, the original
looked like I's to me. But if you have changed them and it works, then no
reason to change back that I can think of.

--
Regards,
Tom Ogilvy


"DianeN" wrote:

Tom, nevermind. I changed the "1" to "i" on both row and column and it works!!
Thanks so much!

"DianeN" wrote:

Hi Tom, thanks so much. I guess when I pasted the code, the "1col" and
"1row" came out looking like "I" or something... or are you saying I need
to change them from "1" to "I" ?

Sorry to be dense. When I copied and pasted your code below, it didn't give
me an error message, it just didn't work on any of the columns.
Thanks

"Tom Ogilvy" wrote:

change
If Target.Column = lCol Then

to
If Target.Column = 7 or Target.column = 12 or _
Target.column = 14 or Target.column = 18 then
Icol = Target.column

--
Regards,
Tom Ogilvy

"DianeN" wrote:

Hi,
Follow up: I first added to original question, but it's really a new
question.

After using the code Debra was kind enough to share, I need to apply the
action (choose from a pull down menu and place each entry
into a new row) to 4 or 5 specific columns. I tried the following but it
didn't work.(see row surrounded by *****)
Thanks for any help.

Here's the code: (the line with all the stars is what I tried).
------
Public Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo exitHandler

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

********lCol = 7 or 14 or 18 or 12 'column with data validation cell****
(I also tried using "And")


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
Application.EnableEvents = False
If Target.Column = lCol Then
If Target.Value = "" Then GoTo exitHandler
If Target.Offset(0, 1).Value = "" Then
lRow = Target.Row
Else
lRow = Cells(Rows.Count, lCol + 1).End(xlUp).Row + 1
End If

Cells(lRow, lCol + 1).Value = Target.Value
End If
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
Autofilter Pulldown daveroblit Excel Programming 8 December 29th 05 07:56 PM
Using value from pulldown box in macro k Excel Programming 2 April 7th 04 08:01 PM
pulldown boxes Gord Dibben[_3_] Excel Programming 0 July 25th 03 12:08 AM
pulldown boxes Debra Dalgleish[_2_] Excel Programming 0 July 25th 03 12:01 AM
pulldown boxes Dan E[_2_] Excel Programming 0 July 24th 03 11:54 PM


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