Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro doesn't work in Excel 97

I have complete a macro in excel 2000, which works
perfectly, however when I try to run the macro on another
computer that running excel 97, I keep getting script
errors and the debug screen appears.

Does anyone have any suggestions what I can change or do
to solve the problem.

The macro is as follows:
Dim EntryCount As Single
Dim empNO As String
Dim empName As String
Dim empSurName As String
Dim empLoc As String
Private Sub CommandButton2_Click()
'Ensure ListBox contains list items
If ListBox1.ListCount = 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = _
ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub

Private Sub cmdDo_Click()
Macro2
End Sub


Private Sub ComboBox2_Change()
For l = 2 To recordno
empNO = Worksheets("sheet1").Range("A" & l)
empName = Worksheets("sheet1").Range("C" & l)
empSurName = Worksheets("sheet1").Range("B" & l)
ComboBox1.AddItem (empNO & "-" & empName & " " &
empSurName)
Next l
End Sub

Sub cmdDo2_Click()
Dim Lastrow As Long

unprotect ("cac")

Range("B800").Select
Selection.End(xlUp).Select
Lastrow = Selection.Row

Range(Cells(6, 5), Cells(Lastrow, 20)).Select

Selection.ClearContents
Range("E6").Select
protect ("cac")


End Sub

Sub CommandButton1_Click()
Delete_it
End Sub


Sub Employee_Click()
New_Emp
End Sub
Sub Print_it_Click()
Dim r As Long

r = Range("e1000").End(xlUp).Row

Range(Cells(1, 1), Cells(r, 18)).PrintPreview

'ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Collate:=True
End Sub



'Help Im not sure how to complete the rest of the code
so that it limited to a select range

Private Sub Worksheet_Change(ByVal Target As Range)
Dim str As String

If Target.Row = 6 Then
If Target.Column = 10 And Target.Column <= 14
Then
str = InputBox("Please enter a date(s).
Example 05-09/07 (dd/mm)", "Date")
If str = "" Then
Exit Sub
End If
str = "(" & Cells(5, Target.Column) & " - " &
str & ")"
Cells(Target.Row, 17).Value = Cells
(Target.Row, 17).Value & str

End If
End If
End Sub

Sub test()
Dim Answer As Integer
Dim Answer2 As Integer
MsgBox "This is just information"

Answer = MsgBox("Enter Info", vbYesNo, "Title here")
If Answer = vbYes Then
'whatever
Else
'user clicked No

End If

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro doesn't work in Excel 97

Is this code behind a worksheet and invoked by clicking on a button from the
control toolbox toolbar?

If yes, then add

activecell.activate

at the top of the code.

Or you can change the .Takefocusonclick to false for that commandbutton (or any
control that has that property).



anthony wrote:

I have complete a macro in excel 2000, which works
perfectly, however when I try to run the macro on another
computer that running excel 97, I keep getting script
errors and the debug screen appears.

Does anyone have any suggestions what I can change or do
to solve the problem.

The macro is as follows:
Dim EntryCount As Single
Dim empNO As String
Dim empName As String
Dim empSurName As String
Dim empLoc As String
Private Sub CommandButton2_Click()
'Ensure ListBox contains list items
If ListBox1.ListCount = 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = _
ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub

Private Sub cmdDo_Click()
Macro2
End Sub

Private Sub ComboBox2_Change()
For l = 2 To recordno
empNO = Worksheets("sheet1").Range("A" & l)
empName = Worksheets("sheet1").Range("C" & l)
empSurName = Worksheets("sheet1").Range("B" & l)
ComboBox1.AddItem (empNO & "-" & empName & " " &
empSurName)
Next l
End Sub

Sub cmdDo2_Click()
Dim Lastrow As Long

unprotect ("cac")

Range("B800").Select
Selection.End(xlUp).Select
Lastrow = Selection.Row

Range(Cells(6, 5), Cells(Lastrow, 20)).Select

Selection.ClearContents
Range("E6").Select
protect ("cac")


End Sub

Sub CommandButton1_Click()
Delete_it
End Sub

Sub Employee_Click()
New_Emp
End Sub
Sub Print_it_Click()
Dim r As Long

r = Range("e1000").End(xlUp).Row

Range(Cells(1, 1), Cells(r, 18)).PrintPreview

'ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Collate:=True
End Sub

'Help Im not sure how to complete the rest of the code
so that it limited to a select range

Private Sub Worksheet_Change(ByVal Target As Range)
Dim str As String

If Target.Row = 6 Then
If Target.Column = 10 And Target.Column <= 14
Then
str = InputBox("Please enter a date(s).
Example 05-09/07 (dd/mm)", "Date")
If str = "" Then
Exit Sub
End If
str = "(" & Cells(5, Target.Column) & " - " &
str & ")"
Cells(Target.Row, 17).Value = Cells
(Target.Row, 17).Value & str

End If
End If
End Sub

Sub test()
Dim Answer As Integer
Dim Answer2 As Integer
MsgBox "This is just information"

Answer = MsgBox("Enter Info", vbYesNo, "Title here")
If Answer = vbYes Then
'whatever
Else
'user clicked No

End If

End Sub


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro doesn't work in Excel 97

The codes are onvoked by clicking a command button within
the spreadsheet.

Will this still work using the activecell.active

-----Original Message-----
Is this code behind a worksheet and invoked by clicking

on a button from the
control toolbox toolbar?

If yes, then add

activecell.activate

at the top of the code.

Or you can change the .Takefocusonclick to false for

that commandbutton (or any
control that has that property).



anthony wrote:

I have complete a macro in excel 2000, which works
perfectly, however when I try to run the macro on

another
computer that running excel 97, I keep getting script
errors and the debug screen appears.

Does anyone have any suggestions what I can change or

do
to solve the problem.

The macro is as follows:
Dim EntryCount As Single
Dim empNO As String
Dim empName As String
Dim empSurName As String
Dim empLoc As String
Private Sub CommandButton2_Click()
'Ensure ListBox contains list items
If ListBox1.ListCount = 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = _
ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub

Private Sub cmdDo_Click()
Macro2
End Sub

Private Sub ComboBox2_Change()
For l = 2 To recordno
empNO = Worksheets("sheet1").Range("A" & l)
empName = Worksheets("sheet1").Range("C" & l)
empSurName = Worksheets("sheet1").Range("B" &

l)
ComboBox1.AddItem (empNO & "-" & empName & " "

&
empSurName)
Next l
End Sub

Sub cmdDo2_Click()
Dim Lastrow As Long

unprotect ("cac")

Range("B800").Select
Selection.End(xlUp).Select
Lastrow = Selection.Row

Range(Cells(6, 5), Cells(Lastrow, 20)).Select

Selection.ClearContents
Range("E6").Select
protect ("cac")


End Sub

Sub CommandButton1_Click()
Delete_it
End Sub

Sub Employee_Click()
New_Emp
End Sub
Sub Print_it_Click()
Dim r As Long

r = Range("e1000").End(xlUp).Row

Range(Cells(1, 1), Cells(r, 18)).PrintPreview

'ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Collate:=True
End Sub

'Help Im not sure how to complete the rest of the code
so that it limited to a select range

Private Sub Worksheet_Change(ByVal Target As Range)
Dim str As String

If Target.Row = 6 Then
If Target.Column = 10 And Target.Column <= 14
Then
str = InputBox("Please enter a date(s).
Example 05-09/07 (dd/mm)", "Date")
If str = "" Then
Exit Sub
End If
str = "(" & Cells(5, Target.Column) & " -

" &
str & ")"
Cells(Target.Row, 17).Value = Cells
(Target.Row, 17).Value & str

End If
End If
End Sub

Sub test()
Dim Answer As Integer
Dim Answer2 As Integer
MsgBox "This is just information"

Answer = MsgBox("Enter Info", vbYesNo, "Title

here")
If Answer = vbYes Then
'whatever
Else
'user clicked No

End If

End Sub


--

Dave Peterson

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro doesn't work in Excel 97

activecell.activate

What happened when you tried it???

(I bet it did (or will) work ok.)

I like the ".takefocusonclick = false" better.

Just because the activecell.activate looks like it isn't doing anything. And
maybe someone will delete it or comment it out without knowing why it was there.





wrote:

The codes are onvoked by clicking a command button within
the spreadsheet.

Will this still work using the activecell.active

-----Original Message-----
Is this code behind a worksheet and invoked by clicking

on a button from the
control toolbox toolbar?

If yes, then add

activecell.activate

at the top of the code.

Or you can change the .Takefocusonclick to false for

that commandbutton (or any
control that has that property).



anthony wrote:

I have complete a macro in excel 2000, which works
perfectly, however when I try to run the macro on

another
computer that running excel 97, I keep getting script
errors and the debug screen appears.

Does anyone have any suggestions what I can change or

do
to solve the problem.

The macro is as follows:
Dim EntryCount As Single
Dim empNO As String
Dim empName As String
Dim empSurName As String
Dim empLoc As String
Private Sub CommandButton2_Click()
'Ensure ListBox contains list items
If ListBox1.ListCount = 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = _
ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub

Private Sub cmdDo_Click()
Macro2
End Sub

Private Sub ComboBox2_Change()
For l = 2 To recordno
empNO = Worksheets("sheet1").Range("A" & l)
empName = Worksheets("sheet1").Range("C" & l)
empSurName = Worksheets("sheet1").Range("B" &

l)
ComboBox1.AddItem (empNO & "-" & empName & " "

&
empSurName)
Next l
End Sub

Sub cmdDo2_Click()
Dim Lastrow As Long

unprotect ("cac")

Range("B800").Select
Selection.End(xlUp).Select
Lastrow = Selection.Row

Range(Cells(6, 5), Cells(Lastrow, 20)).Select

Selection.ClearContents
Range("E6").Select
protect ("cac")


End Sub

Sub CommandButton1_Click()
Delete_it
End Sub

Sub Employee_Click()
New_Emp
End Sub
Sub Print_it_Click()
Dim r As Long

r = Range("e1000").End(xlUp).Row

Range(Cells(1, 1), Cells(r, 18)).PrintPreview

'ActiveWindow.SelectedSheets.PrintOut Copies:=1,
Collate:=True
End Sub

'Help Im not sure how to complete the rest of the code
so that it limited to a select range

Private Sub Worksheet_Change(ByVal Target As Range)
Dim str As String

If Target.Row = 6 Then
If Target.Column = 10 And Target.Column <= 14
Then
str = InputBox("Please enter a date(s).
Example 05-09/07 (dd/mm)", "Date")
If str = "" Then
Exit Sub
End If
str = "(" & Cells(5, Target.Column) & " -

" &
str & ")"
Cells(Target.Row, 17).Value = Cells
(Target.Row, 17).Value & str

End If
End If
End Sub

Sub test()
Dim Answer As Integer
Dim Answer2 As Integer
MsgBox "This is just information"

Answer = MsgBox("Enter Info", vbYesNo, "Title

here")
If Answer = vbYes Then
'whatever
Else
'user clicked No

End If

End Sub


--

Dave Peterson

.


--

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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
Macro doesn't work in Excel 2003 (Con't) Polly[_3_] Excel Programming 3 June 12th 04 01:53 AM
Macro doesn't work in Excel 2003 Polly[_3_] Excel Programming 1 June 9th 04 05:56 AM
Macro: Excel 2000 does not work, XP does... Martin Eckart Excel Programming 5 February 2nd 04 09:56 PM
Solver won't work in macro, Excel 2002 SP1 Martin[_11_] Excel Programming 0 November 7th 03 07:03 PM


All times are GMT +1. The time now is 03:15 PM.

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

About Us

"It's about Microsoft Excel"