Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2011, 03:38 AM
Catalin.B Catalin.B is offline Code to add dates Windows Vista Code to add dates Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

To remove the Monday errors, change this formula in B8 from: =WEEKDAY(B7) to =WEEKDAY(B7;1), and format cell B8 as a number, not as a date (be careful to the red number in formula: the results of the formula means: 1:sunday, 2 monday, etc; if instead of 1 you choose 2 in the formula, 1 is monday, 2 is for tuesday, etc; if choose 3, then 0 is for monday, 1-tuesday, etc)



An easy way to increase with 2 days the second lesson, is to add the red lines in your code: (which will overwrite the values in these cells)

For intStudentSOWCounter = 5 To intTotalNumber
Range("A" & intStudentSOWCounter).Value = Sheets("sow").Range("A" & intStudentSOWCounter).Value
If IsEmpty(Range("A" & intStudentSOWCounter).Value) = True Then
'MsgBox "HOLIDAY"

strRange = "A" & intStudentSOWCounter & ":" & "F" & intStudentSOWCounter
Range(strRange).Select
With Selection.Interior
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.249977111117893
End With

End If

Range("B" & intStudentSOWCounter).Value = Sheets("sow").Range("B" & intStudentSOWCounter).Value
Range("C" & intStudentSOWCounter).Value = Sheets("sow").Range("C" & intStudentSOWCounter).Value
Range("D" & intStudentSOWCounter).Value = Sheets("sow").Range("D" & intStudentSOWCounter).Value
Range("E" & intStudentSOWCounter).Value = Sheets("sow").Range("F" & intStudentSOWCounter).Value
Range("F" & intStudentSOWCounter).Value = Sheets("sow").Range("K" & intStudentSOWCounter).Value

Next
For intStudentSOWCounter = 5 To intTotalNumber Step 2
Range("C" & intStudentSOWCounter + 1).Value = Range("C" & intStudentSOWCounter).Value + 2
Next


The macro will run until row 61 to 65, which has a different input dates in sow
To overcome this, if you do not want to change format in data source, (sow), break the range:



For intStudentSOWCounter = 5 To 60 Step 2
Range("C" & intStudentSOWCounter + 1).Value = Range("C" & intStudentSOWCounter).Value + 2
Next




For intStudentSOWCounter = 66 To intTotalNumber Step 2
Range("C" & intStudentSOWCounter + 1).Value = Range("C" & intStudentSOWCounter).Value + 2
Next



For rows 61 to 65, you need another approach. It's important to know if this type of data in sow sheet will stay on these lines, or can vary, in this case, this approach will not work for those lines
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to add dates Calendar without actual dates parnol01 Project 1 12-16-2015 09:30 AM
Code to add dates Calculating dates Daria11 Word VBA 1 06-08-2011 06:54 PM
Code to add dates Sequential Dates in Word Ultrap3 Word 2 02-04-2011 02:53 PM
Code to add dates Calculated dates. Ziggy-R Word 10 09-28-2010 01:42 AM
Adding dates mkkram Word 0 11-27-2006 09:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft