Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error with Form

Hello all,

I'm having trouble with a form I've created. My form consists of
combobox and several textboxes which displays data from workshee
"METRO". Once the form is displayed, data can also be changed. Th
trouble is I have 2 textboxes that will not write back to the asigne
cell. One of the trouble textboxes enters 2 digit numbers and th
other is a date field. Below is example of my code. Any advice woul
be greatly appreciated.

Private Sub Userform_Initialize()
Dim r As Long
Dim ws As Worksheet
Set ws = Worksheets("METRO")
r = ws.Cells(1, 14).End(xlUp).Offset(1, 0).Row
ComboBox4.Value = ws.Cells(r, "G").Value
ComboBox4.SetFocus
End Sub

Private Sub combobox4_Click()
Dim dt As Long
With crit
If .ComboBox4.ListIndex = -1 Then Exit Sub
For Each Cell In Worksheets("METRO").Range("G2:G400")
dt = ComboBox4.Value
If Cell.Text = dt Then
TextBox1.Value = Cell.Offset(0, -3).Text
TextBox2.Value = Cell.Offset(0, -5).Text
End If
Next
End With
End Sub



Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Worksheets("METRO")
Set rng = .Range("G2:G400")
End With
res = Application.Match(CLng(ComboBox4.Value), rng, 0)
If Not IsError(res) Then
rng(res).Offset(0, -3).Value = TextBox1.Text
End If
End Sub

Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Worksheets("METRO")
Set rng = .Range("G2:G400")
End With
res = Application.Match(CLng(ComboBox4.Value), rng, 0)
If Not IsError(res) Then
rng(res).Offset(0, -5).Value = TextBox2.Text
End If
End Sub



Thank

--
Message posted from http://www.ExcelForum.com

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
#13 type mismatch error on user form for Dave Peterson Janis Excel Discussion (Misc queries) 5 January 17th 08 07:35 PM
Closing Excel user form generates error Ken Warthen Excel Discussion (Misc queries) 0 October 10th 07 08:30 PM
User Form Error theguz Excel Discussion (Misc queries) 3 August 15th 05 10:49 PM
setfocus on multipage tab form gives error message Cheryl Excel Programming 3 July 28th 04 03:07 PM
Run time Error -2147352571 when showing a form Ric Payne Excel Programming 2 October 2nd 03 04:48 AM


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