View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jonah Jonah is offline
external usenet poster
 
Posts: 12
Default Script fails in Excel was okay before.

Sub Button2_Click()

'Start at Row 3
RowIndex = 5

'Set up variables from Master List

Forename = Worksheets("Master List").Cells(RowIndex, 1)
Surname = Worksheets("Master List").Cells(RowIndex, 2)
Group = Worksheets("Master List").Cells(RowIndex, 3)
Role = Worksheets("Master List").Cells(RowIndex, 4)
GenderM = Worksheets("Master List").Cells(RowIndex, 5)
GenderF = Worksheets("Master List").Cells(RowIndex, 6)
Period = Worksheets("Master List").Cells(RowIndex, 7)
OurDate = Worksheets("Master List").Cells(RowIndex, 8)
TLesson = Worksheets("Master List").Cells(RowIndex, 9)
ScoreB = Worksheets("Master List").Cells(RowIndex, 10)
ScoreC = Worksheets("Master List").Cells(RowIndex, 11)
BTE = Worksheets("Master List").Cells(RowIndex, 12)
MSW = Worksheets("Master List").Cells(RowIndex, 13)
SSW = Worksheets("Master List").Cells(RowIndex, 14)
KeySkills = Worksheets("Master List").Cells(RowIndex, 15)
Keywords = Worksheets("Master List").Cells(RowIndex, 16)


'We want to loop down list until we find a blank
'We need both bits of data to be there
Do While (OurDate < "") And (Group < "")

OurDate = Replace(OurDate, "/", "-")

'Combine the two variables, to get a full name
FullName = OurDate & " " & Group

'Copy the Sheet and name it as the Date&Group
Sheets("Lesson Template").Select
Sheets("Lesson Template").Copy After:=Sheets(2)
Sheets("Lesson Template (2)").Name = FullName

'Put the Data into the sheet at appropriate points
'This is done on a co-ordinate basis
' (1,1) means cell A1 I guess and (1,2) means B1 etc
' (2,4) means cell D2

Sheets(FullName).Cells(1, 1) = "Teacher: " + Forename + " " +
Surname
Sheets(FullName).Cells(1, 2) = "Group: " + Group
Sheets(FullName).Cells(1, 3) = " Roll: " + Role
Sheets(FullName).Cells(1, 4) = "Gender: M: " + GenderM
Sheets(FullName).Cells(2, 4) = " F: " + GenderF
Sheets(FullName).Cells(1, 5) = "Period: " + Period
Sheets(FullName).Cells(1, 6) = "Date: " + OurDate
Sheets(FullName).Cells(2, 5) = "Lesson: " + TLesson
Sheets(FullName).Cells(33, 2) = "ScoreB: " + ScoreB
Sheets(FullName).Cells(34, 2) = "ScoreC: " + ScoreC
Sheets(FullName).Cells(3, 1) = "By the end of this lesson all
students will: " + BTE
Sheets(FullName).Cells(3, 2) = "Most students will: " + MSW
Sheets(FullName).Cells(3, 3) = " " + SSW
Sheets(FullName).Cells(5, 1) = "Key skills developed: " +
KeySkills
Sheets(FullName).Cells(5, 2) = "Keywords: " + Keywords


'Move to next row and get new data
RowIndex = RowIndex - 1

Forename = Worksheets("Master List").Cells(RowIndex, 1)
Surname = Worksheets("Master List").Cells(RowIndex, 2)
Group = Worksheets("Master List").Cells(RowIndex, 3)
Role = Worksheets("Master List").Cells(RowIndex, 4)
GenderM = Worksheets("Master List").Cells(RowIndex, 5)
GenderF = Worksheets("Master List").Cells(RowIndex, 6)
Period = Worksheets("Master List").Cells(RowIndex, 7)
OurDate = Worksheets("Master List").Cells(RowIndex, 8)
TLesson = Worksheets("Master List").Cells(RowIndex, 9)
ScoreB = Worksheets("Master List").Cells(RowIndex, 10)
ScoreC = Worksheets("Master List").Cells(RowIndex, 11)
BTE = Worksheets("Master List").Cells(RowIndex, 12)
MSW = Worksheets("Master List").Cells(RowIndex, 13)
SSW = Worksheets("Master List").Cells(RowIndex, 14)
KeySkills = Worksheets("Master List").Cells(RowIndex, 15)
Keywords = Worksheets("Master List").Cells(RowIndex, 16)

Loop

End Sub


Jonah wrote:

I have a script that no longer runs in Excel 2003 under XP Pro. It was
working and now it tells me there is an error.

I can see no error but Excel is determined. Any ideas?

I tried before to send an Excel file but the group does not appear to
accept .xls files. How can I post?

Jonah