ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to code variable reference? (https://www.excelbanter.com/excel-programming/336168-how-code-variable-reference.html)

Amil

how to code variable reference?
 
i have two columns: week, newweek and an integer variable: weekoffset. this
is how the data looks like given a weekoffset value = 2

week newweek
200401 200403 ' < what is the formula for newweek?
200402 200405
200403 0
200405 0

Tom Ogilvy

how to code variable reference?
 
does 200401 mean the first week of 2004.

is 200401 stored as a string? If it is stored as a number

=A1+3

200401 + 2 = 200403

--
Regards,
Tom Ogilvy

"Amil" wrote in message
...
i have two columns: week, newweek and an integer variable: weekoffset.

this
is how the data looks like given a weekoffset value = 2

week newweek
200401 200403 ' < what is the formula for newweek?
200402 200405
200403 0
200405 0




Amil

how to code variable reference?
 
I actually want to set this formula in a macro based on the weekOffset
variable. I think you got me on the right track. The week is stored as a
string. I may have to do a conversion first.

"Tom Ogilvy" wrote:

does 200401 mean the first week of 2004.

yes
is 200401 stored as a string? If it is stored as a number

=A1+3


200401 + 2 = 200403

--
Regards,
Tom Ogilvy

"Amil" wrote in message
...
i have two columns: week, newweek and an integer variable: weekoffset.

this
is how the data looks like given a weekoffset value = 2

week newweek
200401 200403 ' < what is the formula for newweek?
200402 200405
200403 0
200405 0





Amil

how to code variable reference?
 
Opps. I forgot, I actually need the reference to the next row based on the
offset, as such:

weekOffset = 4
week newweek
200449 200501
200450 ...
200451 ...
200452 ...
200501 ...


"Tom Ogilvy" wrote:

does 200401 mean the first week of 2004.

is 200401 stored as a string? If it is stored as a number

=A1+3

200401 + 2 = 200403

--
Regards,
Tom Ogilvy

"Amil" wrote in message
...
i have two columns: week, newweek and an integer variable: weekoffset.

this
is how the data looks like given a weekoffset value = 2

week newweek
200401 200403 ' < what is the formula for newweek?
200402 200405
200403 0
200405 0





STEVE BELL

how to code variable reference?
 
Amil,

Sounds like

=If(right($A3+weekoffset,2) 52, $A3+1000+weekoffset-52, $A3+weekoffset)

--
steveB

Remove "AYN" from email to respond
"Amil" wrote in message
...
Opps. I forgot, I actually need the reference to the next row based on the
offset, as such:

weekOffset = 4
week newweek
200449 200501
200450 ...
200451 ...
200452 ...
200501 ...


"Tom Ogilvy" wrote:

does 200401 mean the first week of 2004.

is 200401 stored as a string? If it is stored as a number

=A1+3

200401 + 2 = 200403

--
Regards,
Tom Ogilvy

"Amil" wrote in message
...
i have two columns: week, newweek and an integer variable: weekoffset.

this
is how the data looks like given a weekoffset value = 2

week newweek
200401 200403 ' < what is the formula for newweek?
200402 200405
200403 0
200405 0








All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com