View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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!