Joined
·
7 Posts
Hello all,
First and foremost I will begin by stating I have gone through more tutorials than I care to remember thus far. With that being said here is my dilema, I hope to create a macro that will change the value of a cell, date, and then print 7 times. Here is my code using the VBA editor:
Sub day_change_print()
Dim i As Integer
Dim current_date As Integer
i = 1
current_date = range(a1).value
Do
current_date = current_date + 1
ActiveWorkbook.PrintOut
i = i + 1
range(a1) = current_date
Loop Until i = 7
End Sub
My problem is line:
current_date = range(a1).value
In debugging I have noticed range(a1) value is empty. Which makes sense, I guess, being I did not pass the value as an argument. So I tried:
Sub day_change_print(ByRef current_date as Integer)
which will not even run.
Next I thought I would give this a try:
current_date = today()
Do
= current_date + 1
ActiveWorkbook.PrintOut
i = i + 1
range(a1) = current_date
Loop Until i = 7
I am just spinning my wheels here so I thought I would break away...clear my mind... swallow my pride... and ask for some advice. So how does one assign a value to a variable form an existing cell's value? Or even better how does one acess the today() function from within a sub routine?
Any thoughts on these topics are greatly appreciated.
First and foremost I will begin by stating I have gone through more tutorials than I care to remember thus far. With that being said here is my dilema, I hope to create a macro that will change the value of a cell, date, and then print 7 times. Here is my code using the VBA editor:
Sub day_change_print()
Dim i As Integer
Dim current_date As Integer
i = 1
current_date = range(a1).value
Do
current_date = current_date + 1
ActiveWorkbook.PrintOut
i = i + 1
range(a1) = current_date
Loop Until i = 7
End Sub
My problem is line:
current_date = range(a1).value
In debugging I have noticed range(a1) value is empty. Which makes sense, I guess, being I did not pass the value as an argument. So I tried:
Sub day_change_print(ByRef current_date as Integer)
which will not even run.
Next I thought I would give this a try:
current_date = today()
Do
= current_date + 1
ActiveWorkbook.PrintOut
i = i + 1
range(a1) = current_date
Loop Until i = 7
I am just spinning my wheels here so I thought I would break away...clear my mind... swallow my pride... and ask for some advice. So how does one assign a value to a variable form an existing cell's value? Or even better how does one acess the today() function from within a sub routine?
Any thoughts on these topics are greatly appreciated.