Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Pulling cell value into macro

I am having trouble pulling a value in a cell into a macro for calculations
The macro is below. The is executed when ENTER is clicked on userform.
It is suppose to pull a date in from the spreadsheet (B125:B176) and
evaluate it against date entered in userform.

Private Sub CommandButton1_Click()
Dim i As Double
Dim date1 As Date
Dim ttltime1, ttltime2 As Double
ttltime1 = Val(TextBox2) - Val(TextBox1)
ttltime2 = Hour(ttltime1) + (Minute(ttltime1) / 60)
With Worksheets("PAS")
For i = 125 To 176
date1 = .Cell(i, 2).Value <<< Problem code
If TextBox1 <= date1 Then
.Cell(i, (TextBox1 - date1) + 3).Value = ttltime2
i = 176
End If
Next
End With
End Sub

Thanks,
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Pulling cell value into macro

Without looking at anything else, it's:

..cells(i, ...
(note the S at the end of Cells)

WLMPilot wrote:

I am having trouble pulling a value in a cell into a macro for calculations
The macro is below. The is executed when ENTER is clicked on userform.
It is suppose to pull a date in from the spreadsheet (B125:B176) and
evaluate it against date entered in userform.

Private Sub CommandButton1_Click()
Dim i As Double
Dim date1 As Date
Dim ttltime1, ttltime2 As Double
ttltime1 = Val(TextBox2) - Val(TextBox1)
ttltime2 = Hour(ttltime1) + (Minute(ttltime1) / 60)
With Worksheets("PAS")
For i = 125 To 176
date1 = .Cell(i, 2).Value <<< Problem code
If TextBox1 <= date1 Then
.Cell(i, (TextBox1 - date1) + 3).Value = ttltime2
i = 176
End If
Next
End With
End Sub

Thanks,
Les


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Pulling cell value into macro

Did you read my response in your other post here "Insert date in correct
cell"? I evaluated the date entered in the userform as to what day of the
week it is. With that I can use math to obtain the date of Monday for that
week. I can now use Cells.Find to find that date on the worksheet, and put
the hours calculation in the correct Offset cell because I already know what
day of the week the date entered is.

I offered to email you my test copy.
Mike F
"WLMPilot" wrote in message
...
I am having trouble pulling a value in a cell into a macro for calculations
The macro is below. The is executed when ENTER is clicked on userform.
It is suppose to pull a date in from the spreadsheet (B125:B176) and
evaluate it against date entered in userform.

Private Sub CommandButton1_Click()
Dim i As Double
Dim date1 As Date
Dim ttltime1, ttltime2 As Double
ttltime1 = Val(TextBox2) - Val(TextBox1)
ttltime2 = Hour(ttltime1) + (Minute(ttltime1) / 60)
With Worksheets("PAS")
For i = 125 To 176
date1 = .Cell(i, 2).Value <<< Problem code
If TextBox1 <= date1 Then
.Cell(i, (TextBox1 - date1) + 3).Value = ttltime2
i = 176
End If
Next
End With
End Sub

Thanks,
Les



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
Pulling out comments with macro dwake Excel Discussion (Misc queries) 5 November 25th 09 05:41 PM
Pulling data from one cell to another Ivan Koh[_2_] Excel Discussion (Misc queries) 3 May 4th 09 06:53 PM
Macro pulling data from 2 worksheets billrl34 Excel Discussion (Misc queries) 2 December 12th 05 08:50 PM
Pulling a Letter from a cell and filling another cell with info nick s Excel Worksheet Functions 16 November 28th 05 04:10 AM
pulling certain data out of a cell D richardson Excel Worksheet Functions 6 May 13th 05 06:10 PM


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