LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Run-Time error '13': Type mismatch

Hi guys,

I've got a spreadsheet that contains macros that remove columns and
re-format the contents of a report. The idea is that the users copy the
report (in xls format) and paste it in this workbook and run the macros by
clicking on a button. My macros assume the first row contains the first record

My users are not computer savvy and pasting the report in my spreadsheet by
selecting any cell other than A1 will mean that my macros will pretty much
butcher the report and the results will be useless. My solution was to unlock
only cell A1 and protect the whole spreadsheet:

Private Sub Worksheet_Activate()

With cells(1, 1)

.Locked = False
.Value = "SELECT THIS CELL AND PASTE THE REPORT RIGHT HERE"
.WrapText = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Font.Bold = True
.Interior.Color = 65535
.Borders.LineStyle = xlContinuous
End With

Columns("A:A").ColumnWidth = 30
Rows("1:1").RowHeight = 26
activeworksheet.Protect

End Sub

This way the users will not have other option but to select cell A1. My plan
is that when they select A1 that would unprotect the worksheet so that they
would be able to paste the report. This is the code I had in mind (notice I
used the SelectionChange event; that may not be the best option but my
knowledge on programming is limited):

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection = cells(1, 1) And Selection.Value = "SELECT THIS CELL AND PASTE
THE REPORT RIGHT HERE" Then
Selection.Value = ""
ActiveSheet.Unprotect
End If
End Sub

The problem is that when I paste the report that immediately triggers the
SelectionChange event and gives me an error message ("Run-time error '13':
Type mismatch"). Anybody know what could be happening here?

Thanks!

A.


 
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
Run time error 13 - type mismatch KG Old Wolf Excel Programming 6 September 27th 09 07:36 PM
Run time error 13, type mismatch cellist Excel Programming 7 February 8th 09 01:30 PM
run-time error 13: Type mismatch? Marko Enula Excel Discussion (Misc queries) 2 February 5th 08 01:00 PM
Run-time error 13, Type Mismatch T De Villiers[_73_] Excel Programming 2 July 31st 06 03:01 PM
Run Time Error '13' Type mismatch David Adamson[_3_] Excel Programming 2 June 10th 04 04:00 AM


All times are GMT +1. The time now is 05:50 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"