Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default May be a Chinese Windows problem??

G'day from Oz. The following macro works perfectly when inserting a
new line(s) into an established spreadsheet. However, when I send the
spreadsheet to our Hong Kong or Taiwan branch, the macro fails "Error
Code 13" with the asterisked line highlighted in yellow. Is this a
problem with Chinese Windows incompatibility?
TIA for your help, Dave


Colon = InStr(ActiveWindow.RangeSelection.Address, ":")
If Colon = 0 Then
MsgBox "Please select Rows to be inserted"
Exit Sub
End If
FirstRow = Left(ActiveWindow.RangeSelection.Address, Colon - 1)
LastRow = Mid(ActiveWindow.RangeSelection.Address, Colon + 1)
MyCheck1 = IsNumeric(Mid(FirstRow, 2, 1)) 'Allows for $ lead
character
If MyCheck1 = False Then
MsgBox "Please select Rows to be inserted"
Exit Sub
End If

Rows(FirstRow & ":" & LastRow).Select '***********
Selection.Copy
Rows(LastRow + 1 & ":" & LastRow + 1).Select
Selection.Insert Shift:=xlDown

Range("A" & FirstRow & ":D" & LastRow).ClearContents

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default May be a Chinese Windows problem??

Dave,
I can confirm this fails on HK Chinese Excel 2K but works on English Excel
2K, although I get a Type Mismatch error on the line:
Rows(LastRow + 1 & ":" & LastRow + 1).Select
Not sure why there should be a difference, but why not use the properties of
the selected range, instead of trying to split the address. e.g.

Private Sub CommandButton1_Click()
Dim SelRange As Range

On Error GoTo Handler
Set SelRange = Selection

FirstRow = SelRange.Row
LastRow = FirstRow + SelRange.Rows.Count - 1

Selection.Copy
Cells(LastRow + 1, 1).Select
Selection.Insert Shift:=xlDown

Range("A" & FirstRow & ":D" & LastRow).ClearContents

Exit Sub
Handler:
Select Case Err.Number
Case 438 'No range selected
MsgBox "Select a range"
Case Else
End Select

End Sub

Probably need some error checking, but you get the idea.

NickHK

"AussieDave" wrote in message
ups.com...
G'day from Oz. The following macro works perfectly when inserting a
new line(s) into an established spreadsheet. However, when I send the
spreadsheet to our Hong Kong or Taiwan branch, the macro fails "Error
Code 13" with the asterisked line highlighted in yellow. Is this a
problem with Chinese Windows incompatibility?
TIA for your help, Dave


Colon = InStr(ActiveWindow.RangeSelection.Address, ":")
If Colon = 0 Then
MsgBox "Please select Rows to be inserted"
Exit Sub
End If
FirstRow = Left(ActiveWindow.RangeSelection.Address, Colon - 1)
LastRow = Mid(ActiveWindow.RangeSelection.Address, Colon + 1)
MyCheck1 = IsNumeric(Mid(FirstRow, 2, 1)) 'Allows for $ lead
character
If MyCheck1 = False Then
MsgBox "Please select Rows to be inserted"
Exit Sub
End If

Rows(FirstRow & ":" & LastRow).Select '***********
Selection.Copy
Rows(LastRow + 1 & ":" & LastRow + 1).Select
Selection.Insert Shift:=xlDown

Range("A" & FirstRow & ":D" & LastRow).ClearContents



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default May be a Chinese Windows problem??


NickHK wrote:
Dave,
I can confirm this fails on HK Chinese Excel 2K but works on English Excel
2K, although I get a Type Mismatch error on the line:
Rows(LastRow + 1 & ":" & LastRow + 1).Select
Not sure why there should be a difference, but why not use the properties of
the selected range, instead of trying to split the address. e.g.

Private Sub CommandButton1_Click()
Dim SelRange As Range

On Error GoTo Handler
Set SelRange = Selection

FirstRow = SelRange.Row
LastRow = FirstRow + SelRange.Rows.Count - 1

Selection.Copy
Cells(LastRow + 1, 1).Select
Selection.Insert Shift:=xlDown

Range("A" & FirstRow & ":D" & LastRow).ClearContents

Exit Sub
Handler:
Select Case Err.Number
Case 438 'No range selected
MsgBox "Select a range"
Case Else
End Select

End Sub

Probably need some error checking, but you get the idea.

NickHK

"AussieDave" wrote in message
ups.com...
G'day from Oz. The following macro works perfectly when inserting a
new line(s) into an established spreadsheet. However, when I send the
spreadsheet to our Hong Kong or Taiwan branch, the macro fails "Error
Code 13" with the asterisked line highlighted in yellow. Is this a
problem with Chinese Windows incompatibility?
TIA for your help, Dave


Colon = InStr(ActiveWindow.RangeSelection.Address, ":")
If Colon = 0 Then
MsgBox "Please select Rows to be inserted"
Exit Sub
End If
FirstRow = Left(ActiveWindow.RangeSelection.Address, Colon - 1)
LastRow = Mid(ActiveWindow.RangeSelection.Address, Colon + 1)
MyCheck1 = IsNumeric(Mid(FirstRow, 2, 1)) 'Allows for $ lead
character
If MyCheck1 = False Then
MsgBox "Please select Rows to be inserted"
Exit Sub
End If

Rows(FirstRow & ":" & LastRow).Select '***********
Selection.Copy
Rows(LastRow + 1 & ":" & LastRow + 1).Select
Selection.Insert Shift:=xlDown

Range("A" & FirstRow & ":D" & LastRow).ClearContents

Thanks Nick, a couple of little tweaks and I've sent it to my HK girls
who've tested it and they've asked me to say thanks a lot - it works
perfectly. Cheers, Dave

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
Problem when input Chinese in Excel 2003 Matthew[_3_] Excel Discussion (Misc queries) 0 September 10th 07 04:05 AM
Problem when input Chinese in Excel 2003 Matthew[_3_] Excel Discussion (Misc queries) 0 September 10th 07 03:45 AM
Excel 2003 traditional chinese to simplified chinese SHO Excel Discussion (Misc queries) 0 December 1st 06 05:23 AM
Write Line problem when writing simplified chinese characters KI LEE Excel Programming 7 August 17th 05 05:41 AM
chinese input problem jj Excel Discussion (Misc queries) 0 July 25th 05 07:34 AM


All times are GMT +1. The time now is 05:42 AM.

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"