Hi all...
I'm trying to set up a simple macro to loop through some number of dates on a sheet and blank out fields next to every instance of Saturday and Sunday.
The only problem I'm having is actually finding the values "Saturday" and "Sunday"
Given a date in this format: 01/01/2009
I can convert to "Thursday"
Problem is, the vba code still "sees" 01/01/2009
I've tried copy / paste special / paste values to no avail.
I've tried changing it via VBA (a few different methods, including strings, formats, etc) with no luck.
Even tried referencing my date cells from another spreadsheet and pasting the values back in. Can't seem to get 01/01/2009 to be "Thursday"
I'm sure I'm missing something pretty simple. Can any of you smack some sense into me?
Thanks
Last edited by VBA Noob; 03-17-2009 at 04:41 PM. Reason: Solving
You can use something like
If Weekday(cell.Value,vbMonday)>=6 Then cell.Offset(,1).Value = ""
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Just another sample
Sub test() Dim Cell As Range For Each Cell In Range("A1:A13") If Weekday(Cell) = 1 Or Weekday(Cell) = 7 Then Cell.Offset(, 1).Value = "" End If Next End Sub
Charles
There are other ways to do this, this is but 1 !
Be Sure you thank those who helped.
IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.
Donkey / Charles... ah, thanks. Very helpful and, of course, successful.
You guys are as generous with your time as you are knowledgeable on the subjects on hand.![]()
Your welcome
Charles
There are other ways to do this, this is but 1 !
Be Sure you thank those who helped.
IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks