N
Newbie
Hello,
How to read, from MSP, the content of an Excel cell which is in Sheet1?
Thanks for help
Newbie
How to read, from MSP, the content of an Excel cell which is in Sheet1?
Thanks for help
Newbie
Newbie said:Hello,
How to read, from MSP, the content of an Excel cell which is in Sheet1?
Thanks for help
Newbie
John said:Newbie said:Hello,
How to read, from MSP, the content of an Excel cell which is in Sheet1?
Thanks for help
Newbie
Newbie,
There are several ways to address a particular cell. Here's one
approach. Let's assume you have created an Excel object in your Project
code. For example,
Set Xl = CreateObject("Excel.Application")
If you want to capture the contents of several cells of Excel data on a
particular Worksheet you might want to identify another object. For
example, this defines Workbook "X" (name or index), Worksheet "1".
Set s = Xl.Workbooks(X).Worksheets(1)
You might want to further define an object for a particular starting
cell. For example, cell A2 on the above sheet.
Set c = s.Range("A2")
Now it is fairly easy to set up a loop to read a group of cells. For
example, this loop will read the first three columns in the first 10
rows below cell A2
For nextrow = 1 To 10
firstdata = c.offset(nextrow,0),Value
secdata = c.offset(nextrow, 1).Value
thirddata = c.offset(nextrow, 2).Value
[etc.]
Next
Hope this helps.
John
Project MVP
Jan De Messemaeker said:Hi,
Once Excel is open (see John's post), I prefer using the Cells method
TheWorkbook.Sheets(1).Cells(x,y).value
HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
http://users.online.be/prom-ade/
+32-495-300 620
Newbie said:Hi John,
Thanks for these detailed explanations !
Newbie