Problem transferring data from Userform to Worksheet

rforob

New Member
Joined
Sep 3, 2014
Messages
5
Hi all,

I have designed a userform where time is entered into several text boxes in the [hh]:mm format. This data is then transferred to a worksheet where I was hoping to utilise the Sum function to add up the total time.

I am formatting the target worksheet cell in to [hh]:mm (in vba) as well as the userform variable prior to transfer. The data appears to transfer successfully and appears in the cell. However when I try and sum a number of these cells the sum always appears as zero. When I select the cell in excel the sum value at the bottom of the excel screen also displays zero.

Hoping somebody has has an idea why this is happening ... I suspect a formatting issue ...

many thanks in advance,

rforob
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
How is the data transferred to the worksheet?
 
Upvote 0
How is the data transferred to the worksheet?
Hi Rory

The time is gathered in the form and then transferred from the sheet on clicking an enter button. Vba from the form reads similar to:

Sheets(sheet1).Range("A2").NumberFormat = "[hh]:mm"
FlightDuration = Format(FlightDuration,"[hh]:mm")
Sheets(sheet1).Range("A2").value = FlightDuration

Following execution the time appears in the cell but as described the sum function shows zero.

cheers,

rforob
 
Upvote 0
Hi Rory

The time is gathered in the form and then transferred from the sheet on clicking an enter button. Vba from the form reads similar to:

Sheets(sheet1).Range("A2").NumberFormat = "[hh]:mm"
FlightDuration = Format(FlightDuration,"[hh]:mm")
Sheets(sheet1).Range("A2").value = FlightDuration

Following execution the time appears in the cell but as described the sum function shows zero.

cheers,

rforob

sorry meant Sent to the sheet
 
Upvote 0
Is FlightDuration the name of the textbox, or a variable? What is actually entered into it? If it actually contains values like 48:15 then you'll need something like:
Code:
Sheets("Sheet1").Range("A2").NumberFormat = "[hh]:mm"
Sheets("Sheet1").Range("A2").Value = TimeSerial(Split(flightduration, ":")(0), Split(flightduration, ":")(1), 0)
 
Last edited:
Upvote 0
Glad to help. Welcome to the forum, by the way! :)
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,674
Members
453,131
Latest member
BeLocke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top