Visual Basic 6 determine the number of active rows
Closed
TomCorrigan
Posts
2
Registration date
Monday April 2, 2018
Status
Member
Last seen
April 4, 2018
-
Updated on Apr 3, 2018 at 04:38 AM
Blocked Profile - Apr 5, 2018 at 04:48 PM
Blocked Profile - Apr 5, 2018 at 04:48 PM
Related:
- Visual Basic 6 determine the number of active rows
- Wvm visual novel - Download - Adult games
- Visual paradigm - Download - Data management
- Ulead photo express 6 - Download - Image editing
- Bloons td 6 free download - Download - Strategy
- Maximum active checking torrents - Guide
3 responses
When you say, "reading", what do you mean? Are you "reading" and storing values into an array? Can you set a variable to false upon finding no data in your ROW?
You are asking a VERY vague question, can that can be answered in any number of about 10 ways. Post some code, and we will try to make a fit!
You are asking a VERY vague question, can that can be answered in any number of about 10 ways. Post some code, and we will try to make a fit!
TomCorrigan
Posts
2
Registration date
Monday April 2, 2018
Status
Member
Last seen
April 4, 2018
Apr 4, 2018 at 05:19 AM
Apr 4, 2018 at 05:19 AM
Dear ac2mark,
Many thanks for your help.
My apologies for the confusion.
What I should have said was "after the Excel file is opened, the number of lines in the spreadsheet, is required before the data can be accessed."
If you attempt to read a line beyond this, the program 'hangs'.
The following example might clarify my problem
Cheers,
Tom
Private Sub Form_Load()
' Declare object variables for Microsoft Excel,
' application workbook, and worksheet objects.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim BookOpen As Boolean
Dim ssRow As Integer
Dim xData() As Double
Dim yData() As Double
' Assign object references to the variables.
' Use Add methods to create new workbook and worksheet objects.
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
Set xlBook = xlApp.Workbooks.Open("c:\Graph.xlsx")
Set xlSheet = xlBook.Sheets.Item(1)
BookOpen = True
' For ssRow = 1 To ? This is where I need the count of active rows.
' There is a function xlsheet.Rows, but I can't see how it's used.
ReDim Preserve xData(ssRow)
ReDim Preserve yData(ssRow)
xData(ssRow) = Val(xlSheet.Cells(ssRow, 1))
yData(ssRow) = Val(xlSheet.Cells(ssRow, 2))
' Next ssRow
' Close Microsoft Excel with the Quit method.
xlApp.Quit
' Release the objects.
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
End
End Sub
Many thanks for your help.
My apologies for the confusion.
What I should have said was "after the Excel file is opened, the number of lines in the spreadsheet, is required before the data can be accessed."
If you attempt to read a line beyond this, the program 'hangs'.
The following example might clarify my problem
Cheers,
Tom
Private Sub Form_Load()
' Declare object variables for Microsoft Excel,
' application workbook, and worksheet objects.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim BookOpen As Boolean
Dim ssRow As Integer
Dim xData() As Double
Dim yData() As Double
' Assign object references to the variables.
' Use Add methods to create new workbook and worksheet objects.
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
Set xlBook = xlApp.Workbooks.Open("c:\Graph.xlsx")
Set xlSheet = xlBook.Sheets.Item(1)
BookOpen = True
' For ssRow = 1 To ? This is where I need the count of active rows.
' There is a function xlsheet.Rows, but I can't see how it's used.
ReDim Preserve xData(ssRow)
ReDim Preserve yData(ssRow)
xData(ssRow) = Val(xlSheet.Cells(ssRow, 1))
yData(ssRow) = Val(xlSheet.Cells(ssRow, 2))
' Next ssRow
' Close Microsoft Excel with the Quit method.
xlApp.Quit
' Release the objects.
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
End
End Sub
There is a caveat to this fucntion, you must have the sheet you want counted, set to the active sheet. After that, you can initialize a variable with:
Don't forget to issue a NEXT statement so the code know when to loop!
I hope this helps!
Have FUN!
Rowcount = Cells(ThisWorkbook.Worksheets(YOUR_PREVIOUSLY_ACTIVATED_SHEET).Rows.Count,
1).End(xlUp).Row
Don't forget to issue a NEXT statement so the code know when to loop!
I hope this helps!
Have FUN!