Mikz
Mikz

Reputation: 591

Formula to convert a week number to month

I am trying to implement VBA code for converting the week number to month Name.

I have a sheet in which column "A" contains week number from 1 to 52 . The week number 1 starts from column A3. I want the corresponding month Name for the week number to be printed.

I tried a formula like this

=MONTH(DATE(YEAR(NOW()),1,1)+(B1*7))

The reason I tried an formula fisrt is to get the idea and then converting the formula to VBA.

I am just getting the formula printed in my cell. Can anyone help me with this?

Upvotes: 0

Views: 1293

Answers (1)

mojo3340
mojo3340

Reputation: 549

here you go:

dim i as long
dim n as long

n=sheets("Sheet1").cells(Rows.count,1).end(xlup).row

for i = 1 to n

cells(i,3).formula = "=MONTH(DATE(YEAR(NOW()),1,1)+(RC[-1]*7))"

next i

Upvotes: 1

Related Questions