#1   Report Post  
Posted to microsoft.public.excel.misc
DCSwearingen
 
Posts: n/a
Default User Form Problem


I have done some reading on using User Forms within VBA.

I am taking data from the form and putting it to an Excel worksheeet.

Here is the code I have so far... This all works...

Private Sub cmdSaveData_Click()
Dim LastRow As Object
Sheets("DailyData").Select

Set LastRow = Sheet1.Range("a65536").End(xlUp)

LastRow.Offset(1, 0).Value = txtDate.Text
LastRow.Offset(1, 1).Value = txtRawPounds.Text
LastRow.Offset(1, 2).Value = txtRawSolids.Text
LastRow.Offset(1, 3).Value = txtFrenchFryPounds.Text
LastRow.Offset(1, 4).Value = txtBatterPounds.Text
LastRow.Offset(1, 5).Value = txtFrSpPounds.Text
LastRow.Offset(1, 6).Value = txtUnFrSpPounds.Text
LastRow.Offset(1, 7).Value = txtBakedPounds.Text
LastRow.Offset(1, 8).Value = txtFrenchFryOil.Text
LastRow.Offset(1, 9).Value = txtFrSpOil.Text
LastRow.Offset(1, 10).Value = txtBatterOil.Text
LastRow.Offset(1, 11).Value = txtBatterPowder.Text
LastRow.Offset(1, 12).Value = txtFrenchFrySolids.Text
LastRow.Offset(1, 13).Value = txtBatterSolids.Text
LastRow.Offset(1, 14).Value = txtFrSpSolids.Text
LastRow.Offset(1, 15).Value = txtUnFrSpSolids.Text
LastRow.Offset(1, 16).Value = txtBakedSolids.Text

' <---------Question Area---------

Unload Me
End Sub

The User Form will be compased of six tabbed pages of input, the above
is from the first page.

I need to know how to write the code to have the LastRow.offset(1,17)
do a calculation based on adding the pounds from the production lines
(Offset 1,3 throught 1,7 above) and dividing by the raw pounds (Offset
1,1 above)

I have tried several things, but I always seem to get an absolute
reference and the next new row has the same result as the previous
existing row.

Thanks for the help in the past, I know this is something I will
probably slap my forehead and so "Dummy!"


--
DCSwearingen


------------------------------------------------------------------------
DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=496826

  #2   Report Post  
Posted to microsoft.public.excel.misc
Leith Ross
 
Posts: n/a
Default User Form Problem


Hello Dennis,

Here is the routine...


Code:
--------------------

Sub CalcPounds()

Dim LastRow As Range
Dim Pounds As Single
Dim RawPounds As Single

Set LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)

For C = 3 To 7
Pounds = Pounds + ActiveSheet.Cells(LastRow.Row + 1, C).Value
Next C

RawPounds = ActiveSheet.Cells(LastRow.Row + 1, "A").Value
Pounds = Pounds / RawPounds

End Sub

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=496826

  #3   Report Post  
Posted to microsoft.public.excel.misc
DCSwearingen
 
Posts: n/a
Default User Form Problem


I am not in the office today, but I will try this out when I return next
week!!


--
DCSwearingen


------------------------------------------------------------------------
DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=496826

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
User form Mike Rogers New Users to Excel 7 December 16th 05 05:07 PM
Dialog & User Form bach New Users to Excel 2 August 13th 05 09:35 PM
User Form in VB = TextBox Kel Excel Discussion (Misc queries) 1 August 11th 05 12:26 AM
Positioning 2 User Forms mully New Users to Excel 3 June 11th 05 08:15 PM
Printing Part of User Form mully New Users to Excel 1 May 26th 05 08:22 AM


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