ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reading cells from a spreadsheet using VB (https://www.excelbanter.com/excel-programming/273288-re-reading-cells-spreadsheet-using-vbulletin.html)

Bob Kilmer

reading cells from a spreadsheet using VB
 
Dan,
The obvious question is does Selection contain more than one c? Step thru
the code. Example: Set a breakpoint at the For Each line. Run the code (F5).
When it stops at the breakpoint, enter "Print Selection.Cells.Count" into
the Immediate window (Ctrl+G) and, with your cursor on the line, hit Enter
to see a count of cells in Selection. If it is one (1) and you expect more,
find out why. If OK, clear the first break point and set a break point at
SendKeys and run the code. When it stops at the next break point, see what
the variable values are and compare them to what you expect. Hit run again.
Execution should stop at the break point each time thru the loop. If the
code never stops at a breakpoint, step into and through the code using F8,
checking the state of variables and path of execution as you go.

I suggest you declare all variables (declare c as a range) and make it
explicit that you want the value of each CELL in Selection. Moreover, go to
ToolOptionsEditor. Check 'Require Variable Declaration.'

Dim sep as String
Dim Content As String
Dim c As Range
For Each c in Selection.Cells
etc.

Bob Kilmer

"Dan" wrote in message
...
I'm trying to read cells from a spreadsheet using VB/macro
to automate some data entry on another system. I did this
about 4 years ago, I think w/95. I have the code but it's
not working with excel 2000, vb6. It only reads the first
cell, posts the data to the screen and stops. Any
assistance would be greatly appreciated. Here is the code:

Sub Send_rows()

AppActivate "Application" ' Activate
Oracle Applications

DoEvents '

<snip




All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com