Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default write error - even when no macros run

Morning all,

I am having major problems

I am using a combo box (cmbindivlist) on a form (frmindiv) which is
populated from a column on form (d1) to view existing worksheets or create a
new one if it doesn't exist!

I tried:

------------------------------------------------------------------------
Private Sub cmdviewi_Click()

If Cmbindivlist.ListIndex -1 Then
indivsh = Cmbindivlist.Name
If sheetexists(indivsh) Then

Sheets(Cmbindivlist.Name).Select

Else: Call makesheeti

End If
Sheets(indivsh).Visible = True
Range("a1:a1").Select
End If

End Sub

the sheetexsts function is in a separate module:

Public Function sheetexists(ByVal indivsh) As Boolean
' Returns TRUE if sheet exists in the active workbook
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(indivsh)
If Err = 0 Then sheetexists = True Else: sheetexists = False

End Function
(obtained and tweaked from this site)
-------------------------------------------------------------------------
But that didbn't work no matter how many times I tweaked and fiddled.

Then I tried:
-----------------------------------------------

Private Sub cmdviewi_Click()

If Cmbindivlist.ListIndex -1 Then
indivsh = Cmbindivlist.Text

For Each wks In Worksheets
If wks.Name = indivsh Then
Sheets(Cmbindivlist.Text).Select

On Error GoTo makesheeta
Exit Sub
End If

Next wks

makesheeta:


Sheets("template").Copy befo=Sheets("template")
ActiveSheet.Name = indivsh



End If
End Sub

-------------------------------------------------
which appeared to work....if the sheet existed it gave it focus and brought
it to the front and if the sheet didn't exist it copied te template and
renamed it to the selected name from the combo box!

Wey Hey you're thinking (I know I did!) - but no!!!!!! THE HORROR!!!!!!

Write this code to a workbook and excel produces a 'memory could not be
written' error, closes down, locks my 'personal macro' file for editing, and
lets you open the file again only as 'read only' or 'notify' etc.. unless you
restart the PC

EVEN IF YOU DON'T RUN THIS OR ANY OTHER MACRO IN THE WORKBOOK!!!!!!!!

EVEN IF YOU DON'T SAVE ANYTHING! - JUST OPEN AND CLOSE IT!

Please help before I lose ALL my hair!
--
Jabba
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
Excel 2000 with macros slows to write to W2k3/XP disk or shares Chris V. Excel Discussion (Misc queries) 0 May 3rd 06 07:37 AM
How to write macros Aries6 Excel Discussion (Misc queries) 2 December 16th 05 03:40 PM
Macros that write data to a new spreadsheet? StargateFanFromWork Excel Programming 3 June 24th 04 04:08 PM
Error when using macro to write formula to cell Patti[_3_] Excel Programming 3 April 2nd 04 07:49 PM
Possible to write Excel macros in JavaScript? Christopher M. Balz Excel Programming 0 December 16th 03 10:27 PM


All times are GMT +1. The time now is 12:30 PM.

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"