Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50194

Two Questions - Export data from form, but Always to the second top row. ALso, - Date Time

$
0
0
Hi,
can anyone please tell me the code for exporting data from the VBA Form to the Excel sheet, (2007) but every time , the second row should be updated, meaning, the one just below the column titles.... I want user to see the latest report on top of the sheet...
Below is the code that does the job but it goes downwards, if you know what I mean.

Second question is about the label "date/time" ... I set it to "Now" and it does display the date/time on the form...
But, when I click on the OK button to export data from the form into the excel sheet, it exports the date/time of the moment when the form is loaded, not the moment when I clicked OK (e.g. 5 minutes later or 6 hours later when I finish the report).
Anyone?
Thanks

Code:

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Sheet1 Active
Sheets(1).Activate

'Determine EmptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1

'Export Data to worksheet

Cells(emptyRow, 1).Value = ReportTextBox.Value
Cells(emptyRow, 2).Value = Label60.Caption
Cells(emptyRow, 3).Value = Combobox1.Value

is it this one

Code:

ActiveSheet.Cells(ActiveCell.Row, 2).Select

Also, a time caption
Code:

'  Labe60.Text = TimeOfday
        Label60.Caption = Now


Viewing all articles
Browse latest Browse all 50194

Trending Articles