I would like to ask your help please.
I'm trying to build a form where user will have the option to paste data on the form spreadsheet, after I want to recover that data by VBA to insert it on table.
how can I use that Active X spreadsheet ?? how can I know what value are on cell A1 for example ????
please help me.
You can refer to the object in a bound or unbound control:
Private Sub Command3_Click()
Set obj = Me.OLEUnbound0.Object
MsgBox obj.ActiveSheet.[a1]
End Sub
I think that it would be easier to just get the user to give you the name of the Excel sheet with the data. I suspect there will be quite a bit of training involved in this method.
Set mySht = Me.Spreadsheet
With mySht With .ActiveWindow.ActiveSheet lastColumn = .UsedRange.Columns(mySht.ActiveWindow.ActiveSheet.UsedRange.Columns.Count).Column lastrow = .Range("A" & mySht.ActiveWindow.ActiveSheet.Rows.Count).End(xlUp).Row End With End With
MsgBox "Table dimention, Lines = " & lastrow & " columns = " & lastColumn
ReDim linea(lastColumn)
For i = 1 To lastrow For j = 1 To lastColumn
mySht.Cells(i, j) 'something with the cell (i, j)
Next ' end line
Next ' next Line ' dispose Set mySht = Nothing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.