Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Please help to correct syntex error

I am trying to creat a spreadsheet calendar for 2006 with the following VBA
code.

Dim i, j, k As Integer
For i = 1 To 12
dt = DateSerial(2005, i + 1, 1)
For j = 1 To Day(DateSerial(2006, i + 1, 0))
week_Text= Text(Date(2006,i,1),"ddd"))
Cells(i + 6, j).Value = week_Text
If week_Text = "Sat" Or week_Text = "Sun" Then
For k = i To i + 5
Cells(k, j).Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Next
Else
End If
Next
Next
End Sub

I got an error message on "week_Text= Text(Date(2006,i,1),"ddd"))".
Would anyone help?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Please help to correct syntex error

Text() is a worksheet function that isn't available in VBA. Use the
Format() method instead.


In article ,
"james" wrote:

I am trying to creat a spreadsheet calendar for 2006 with the following VBA
code.

Dim i, j, k As Integer
For i = 1 To 12
dt = DateSerial(2005, i + 1, 1)
For j = 1 To Day(DateSerial(2006, i + 1, 0))
week_Text= Text(Date(2006,i,1),"ddd"))
Cells(i + 6, j).Value = week_Text
If week_Text = "Sat" Or week_Text = "Sun" Then
For k = i To i + 5
Cells(k, j).Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Next
Else
End If
Next
Next
End Sub

I got an error message on "week_Text= Text(Date(2006,i,1),"ddd"))".
Would anyone help?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Please help to correct syntex error

But I saw a guy with initials JEM post something like:

Dim myDate As Date
myDate = Date
MsgBox Application.Text(myDate, "mm/dd/yyyy")

He didn't use this for one of the formats that VBA's Format has built in (that
JEM is way too smart for that), but he used it for a format that was available
in excel (using Text()).

I remember it 'cause I was doing something completely stupid at the time to get
to this!



JE McGimpsey wrote:

Text() is a worksheet function that isn't available in VBA. Use the
Format() method instead.

In article ,
"james" wrote:

I am trying to creat a spreadsheet calendar for 2006 with the following VBA
code.

Dim i, j, k As Integer
For i = 1 To 12
dt = DateSerial(2005, i + 1, 1)
For j = 1 To Day(DateSerial(2006, i + 1, 0))
week_Text= Text(Date(2006,i,1),"ddd"))
Cells(i + 6, j).Value = week_Text
If week_Text = "Sat" Or week_Text = "Sun" Then
For k = i To i + 5
Cells(k, j).Select
With Selection.Interior
.ColorIndex = 48
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Next
Else
End If
Next
Next
End Sub

I got an error message on "week_Text= Text(Date(2006,i,1),"ddd"))".
Would anyone help?

Thanks in advance.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Please help to correct syntex error

Obviously a smarter JEM than me...

In article ,
Dave Peterson wrote:

But I saw a guy with initials JEM post something like:

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Please help to correct syntex error

Aw, that's not possible <gd&r.

JE McGimpsey wrote:

Obviously a smarter JEM than me...

In article ,
Dave Peterson wrote:

But I saw a guy with initials JEM post something like:


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper syntex to use jannie Excel Discussion (Misc queries) 1 February 10th 10 08:26 PM
Syntex Error ?? Paul Cooke Excel Discussion (Misc queries) 4 December 9th 05 01:54 PM
How do I correct the #DIV/0! error? sony654 Excel Worksheet Functions 5 April 17th 05 09:52 AM
Date format within a text syntex? Brw Excel Worksheet Functions 2 January 26th 05 02:13 PM
What syntex to find text Robert Christie[_3_] Excel Programming 2 January 24th 05 04:53 AM


All times are GMT +1. The time now is 10:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"