Forum Discussion
Variable Cell Reference
I do not simply want to directly add the cells inside Range(). I want to add an integer to "day" and use that to reference day1, day2, day3, etc. which are the different cells to change. I need it this way so that I can change the number of iterations within the For loop. For example:
Dim days As Integer
days = 31
Dim day1 As String
day1 = "A1"
Dim day2 As String
day2 = "K2"
Dim day3 As String
day3 = "H7"
Dim day4 As String
day4 = "G4"
..........All the Way to day37 with different cell values......
For k = 1 To days
Range(day & k).Value = "Hello"
Next k
-------------------------------------------------------------
In the example (which doesn't work), I want all the cells that are referenced in the day1, day2, day3, all the way to "day & days" to have the value "Hello". This way I can change the number of iterations of the For loop by changing the days variable. Also, if I want all I have to do is change the value of day1, day2, etc. instead of having to manually change the cells within Range() in my entire code.
I tried to find a solution for you, but I could not.
Try to post your request https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel, this the best place to get support!