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: 18
Default Code runs without error but doesn't print output

Hi Everyone

I am using the following code to make a userform enter into a worksheet the
data collected following a button press. It does not find the cell as it
gives NA in the messagebox.

If I do Not make an entry in the textbox (txtdate) the code does search and
run correctly because it finds the next blank cell in the column and returns
$A$96

I have thought it may be due to the way that the formatting was set and that
it might not match in the computers eye. Do I need CLng or is it not this?

The calendar name is calendar1 and I have tried this in the place of
txtdate.value

If you have any ideas please let me know.

Rob

Code ****
Private Sub cmdenterinfo_Click()

Dim TheDate As String
Dim CellAddr As Variant

ActiveWorkbook.Sheets("York Naburn").Activate

TheDate = txtdate.Value

CellAddr = FindDateAddress("York Naburn", "A", TheDate)

MsgBox "The date " & TheDate & " is in cell " & CellAddr

If Not CellAddr = "NA" Then
With Range(CellAddr)
.Offset(0, 3) = txtnaburncrude.Value
.Offset(0, 4) = txtsbr1amm.Value
.Offset(0, 5) = txtsbr1bod.Value
.Offset(0, 6) = txtsbr2amm.Value
.Offset(0, 7) = txtsbr2bod.Value
.Offset(0, 8) = txtsbr3amm.Value
.Offset(0, 9) = txtsbr3bod.Value
.Offset(0, 10) = txtsbr4amm.Value
.Offset(0, 11) = txtsbr4bod.Value
.Offset(0, 12) = txt3wksamm.Value
.Offset(0, 13) = txt3wksbod.Value
.Offset(0, 18) = txtsbr1sbl.Value
.Offset(0, 19) = txtsbr2sbl.Value
.Offset(0, 20) = txtsbr3sbl.Value
.Offset(0, 21) = txtsbr4sbl.Value
.Offset(0, 24) = txtsbr1mlss.Value
.Offset(0, 25) = txtsbr1mlss.Value
.Offset(0, 26) = txtsbr1mlss.Value
.Offset(0, 27) = txtsbr1mlss.Value
End With
End If

Range("A1").Select

Unload Me

End Sub

Public Function FindDateAddress(SheetName, ColLetter, TheDate) As String

Dim c As Variant

With Worksheets(SheetName).Columns(ColLetter & ":" & ColLetter)
Set c = .Find(TheDate, LookIn:=xlFormulas, lookat:=xlPart)
If Not c Is Nothing Then
FindDateAddress = c.Address
Else
FindDateAddress = "NA"
End If
End With
End Function




 
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
vba code runs...need spaces ........ Wanna Learn Excel Discussion (Misc queries) 2 January 20th 09 12:44 PM
VBA code that only runs when a worksheet is active Paul James[_3_] Excel Programming 4 December 11th 03 01:05 AM
Code runs different in a commandbutton than a macro why? Neal Miller Excel Programming 7 December 7th 03 02:41 AM
Code runs every other time Mike Waldron Excel Programming 1 September 27th 03 03:54 PM
How to keep from going dizzy when my code runs TBA[_2_] Excel Programming 3 September 23rd 03 11:33 PM


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