LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
pwz pwz is offline
external usenet poster
 
Posts: 5
Default Insert Code Problem

Hello All,

I wrote the codes below a few days ago and encountered problem. The code
always halted at the "row insert" statement (marked with ?). The error
message was "Run-time error 1004 : Application-defined or object-defined
error". The error also caused Excel to close for auto-recovery. I had
tried to run the statement in the immediate window. They worked fine.
Then, you all become my last resort.

My Excel version is XP. I just want to monitor the user input of a combox
box named cbItem. If input item is not found from the list, it will then
be added to the list for future selection. Sheet "Others" is another
worksheet and locates in the same workbook. It is hidden initially.

Thanks in advance!

Patrick


Private Sub cbItem_KeyDown( _
ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = vbKeyTab Or KeyCode = vbKeyReturn Then
If cbPayee.MatchFound Then
With cbMethod
.Activate
.SelStart = 0
.SelLength = 10
End With
Else
ans = MsgBox("Are you want to add NEW item?", _
vbQuestion + vbYesNo, "Item Not Found")
If ans = vbYes Then
strg = Application.InputBox("Please provide its CODE.", _
"New Item", Type:=1)
Sheets("others").Visible = True
Sheets("others").Activate
? Sheets("others").Range("slmaster").Range(Cells(3, 1), _
Cells(3, 3)).Insert Shift:=xlDown
Sheets("others").Range("slmaster").Cells(3, 1).Value _
= Application.WorksheetFunction.Proper(cbItem.Text)
Sheets("others").Range("slmaster").Cells(3, 2).Value = strg
End If
End If
End If
End Sub


 
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
Insert Code Steph Excel Worksheet Functions 0 February 27th 10 06:08 PM
insert vba code to new workbook Jive Excel Worksheet Functions 2 March 5th 08 02:12 PM
How to insert code Karl Excel Discussion (Misc queries) 3 January 8th 07 11:01 PM
Insert Code Derek Y via OfficeKB.com New Users to Excel 3 October 17th 05 03:48 AM
**HELP** VBA code to insert subtotals farmer[_2_] Excel Programming 1 May 28th 04 08:24 PM


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