Replace Weeknum formula in VBA

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
Hi,

I'm trying to get rid of code that places formulas in cells. One of the formulas I have is sheet1.Range("M3:M" & LastrowC).Formula = "=weeknum(K3)"

I tried to massage the code below, but had no luck. Any suggestions?

This works:
With sheet1.Range("L3:L" & LastrowC)
.Value = Evaluate(Replace("if(@<>"""",text(@,""MMMM""),"""")", "@", .Offset(, -1).Address))
End With

This doesn't:
With sheet1.Range("M3:M" & LastrowC)
.Value = Evaluate(Replace("if(@<>"""",weeknum(@),"""")", "@", .Offset(, -2).Address))
End With
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try
Code:
With Sheet1.Range("M3:M" & 1000)
   .Value = Evaluate(Replace("if(@<>"""",weeknum(value(@)),"""")", "@", .Offset(, -2).Address))
End With
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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