Debugging Evaluation function

Mazen

New Member
Joined
Feb 16, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello,, I have a syntax error in [YELLOW LINE]

Sub Rectángulo4_Haga_clic_en()

Dim Rango As Range

Dim Celda As Range

Dim Lista As Range

Set Rango = Worksheets("Print").Range("B2:B24")

Set Lista = Evaluate(Rango.Validation.Formula1) <--- THIS IS YELLOW LINE

For Each Celda In Lista

Rango = Celda.Value

ActiveSheet.PrintOut

Next

End Sub


My goal is to take each line from pic 2, put it in five places in pic 1, and print, as much as there are rows in pic 2.
Please help
Thank you
 

Attachments

  • 1.jpg
    1.jpg
    48.7 KB · Views: 10
  • 2.jpg
    2.jpg
    88.9 KB · Views: 11

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hello,, I have a syntax error in [YELLOW LINE]

Sub Rectángulo4_Haga_clic_en()

Dim Rango As Range

Dim Celda As Range

Dim Lista As Range

Set Rango = Worksheets("Print").Range("B2:B24")

Set Lista = Evaluate(Rango.Validation.Formula1) <--- THIS IS YELLOW LINE

For Each Celda In Lista

Rango = Celda.Value

ActiveSheet.PrintOut

Next

End Sub


My goal is to take each line from pic 2, put it in five places in pic 1, and print, as much as there are rows in pic 2.
Please help
Thank you
I solved it by this,, and would appreciate a simplyfing ideas for a beginner, thank you.

Sub PrintAll()


'thank you sir for your order
'I have started this from scratch, to serve you ASAP


'First thing I want to know how many times are in my loop and I need a reference value in A2
Sheets("Data").Select
Range("H1").FormulaR1C1 = "=LOOKUP(2,1/(C[-7]<>""""),C[-7])"
Range("A2").FormulaR1C1 = "ref"


' Now let us start our loop, defining a very useful and simple (i)


' I know this can be factorized,, but it is working,, and super fast
' we find title row, offset no navigate, upon our (I)
' and let's copy, paste, and pring each (i)

For I = 1 To Range("H1").Value
Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Offset(I, 0).Select
Selection.Offset(0, 1).Copy
Sheets("Print").Select
Range("B2:B13").Select
ActiveSheet.Paste

Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Offset(I, 0).Select
Selection.Offset(0, 2).Copy
Sheets("Print").Select
Range("B24:B38").Select
ActiveSheet.Paste

Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Offset(I, 0).Select
Selection.Offset(0, 3).Copy
Sheets("Print").Select
Range("B41:B50").Select
ActiveSheet.Paste

Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Offset(I, 0).Select
Selection.Offset(0, 4).Copy
Sheets("Print").Select
Range("B59:B77").Select
ActiveSheet.Paste

Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Offset(I, 0).Select
Selection.Offset(0, 5).Copy
Sheets("Print").Select
Range("B84:B95").Select
ActiveSheet.Paste

ActiveSheet.PrintOut


Next I

' finally, let's notify completion.
MsgBox "All Printed"

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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