Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default urgent-looping through data validation list then printing as per each value

Hey all,

I feel like this is a simple issue but am trying to get my head around
using VBA.

I need a code that loops thorugh a data validation list and as it
selects each value in the list, prints out the active worksheet.
(guessing some sort of loop is needed)sorry for sounding like such a
beginner.

thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default urgent-looping through data validation list then printing as per each value

The following code should get you started. It assumes that
Worksheets(1).Range("A1") has a List type validation with the list pointing
to a range of cells. There is no error check to ensure that this is true.

Sub AAA()
Dim DV As Validation
Dim S As String
Dim DVRng As Range
Dim R As Range

Set DV = Worksheets(1).Range("A1").Validation
S = DV.Formula1
S = Mid(S, 2)
Set DVRng = DV.Parent.Worksheet.Range(S)
For Each R In DVRng
DV.Parent.Value = R.Value
DV.Parent.Worksheet.PrintOut
Next R
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"kidkarma" wrote in message
oups.com...
Hey all,

I feel like this is a simple issue but am trying to get my head around
using VBA.

I need a code that loops thorugh a data validation list and as it
selects each value in the list, prints out the active worksheet.
(guessing some sort of loop is needed)sorry for sounding like such a
beginner.

thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default urgent-looping through data validation list then printing as per each value

If the data validation list is from a range on the sheet and you don't know
what it is (if you do, just loop through that).

In each case, assume I5 is the cell with the data validation:

Sub LoopListRange()
Dim as String, rng as Range, cell as Range
s = Evaluate(Activesheet.Range("I5").Validation.Formul a1)
set rng = Activesheet.Range(s)
for each cell in rng
Activesheet.Range("I5").Value = cell.Value
Activesheet.Printout
Next
End Sub

If the list is hand entered such as John,Jack,Jill,Mary

Sub LoopListArray()
Dim s as Variant, i as Long
s = Split(Activesheet.Range("I5").Validation.Formula1, ",")
for i = lbound(s) to ubound(s)
ActiveSheet.Range("I5").Value = s(i)
ActiveSheet.Printout
Next
End Sub

--
Regards,
Tom Ogilvy


"kidkarma" wrote in message
oups.com...
Hey all,

I feel like this is a simple issue but am trying to get my head around
using VBA.

I need a code that loops thorugh a data validation list and as it
selects each value in the list, prints out the active worksheet.
(guessing some sort of loop is needed)sorry for sounding like such a
beginner.

thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default urgent-looping through data validation list then printing as per each value

correction on the first one

Sub LoopListRange()
Dim rng as Range, cell as Range
Set rng = Evaluate(Activesheet.Range("I5").Validation.Formul a1)
for each cell in rng
Activesheet.Range("I5").Value = cell.Value
Activesheet.Printout
Next
End Sub

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
If the data validation list is from a range on the sheet and you don't
know what it is (if you do, just loop through that).

In each case, assume I5 is the cell with the data validation:

Sub LoopListRange()
Dim as String, rng as Range, cell as Range
s = Evaluate(Activesheet.Range("I5").Validation.Formul a1)
set rng = Activesheet.Range(s)
for each cell in rng
Activesheet.Range("I5").Value = cell.Value
Activesheet.Printout
Next
End Sub

If the list is hand entered such as John,Jack,Jill,Mary

Sub LoopListArray()
Dim s as Variant, i as Long
s = Split(Activesheet.Range("I5").Validation.Formula1, ",")
for i = lbound(s) to ubound(s)
ActiveSheet.Range("I5").Value = s(i)
ActiveSheet.Printout
Next
End Sub

--
Regards,
Tom Ogilvy


"kidkarma" wrote in message
oups.com...
Hey all,

I feel like this is a simple issue but am trying to get my head around
using VBA.

I need a code that loops thorugh a data validation list and as it
selects each value in the list, prints out the active worksheet.
(guessing some sort of loop is needed)sorry for sounding like such a
beginner.

thanks!





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
data validation list: how do i 'force' a user to enter data from the list? showsomeidnow Excel Discussion (Misc queries) 4 May 1st 07 05:49 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Programming 0 November 7th 06 12:54 PM
urgent. looping thru all records and applynig formula to get new results shirley Excel Programming 2 April 29th 04 04:32 AM


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