Hi All,
My problem is trying to figure out how to get the numbers
from a range of cells in Excel into an array (double) in a
VB.NET program, do something with the array, and then send
it back to the spreadsheet. I AM able to open an exiting
Excel spreadsheet and do this with a single cell but not
an array. In addition, I can send an array from the
VB.NET program to a range of cells in Excel but I can't
for the life of me figure out how to get the numbers from
a range of cells in Excel into an array in the VB.NET
program. I'm sure it would be easy to use a loop and
bring in one cell at a time but my range of cells is very
large and it would be very time consuming to do it that
way. I'd like to learn how to work with arrays.
Here is a small example of the code I tried that seems
like it should work but it doesn't:
Dim x(9) as Double
'Read in the values of a range of cells
x = xlSheet.Range(x lSheet.Cells(50 , 10), _
xlSheet.Cells(5 0, 19)).Value
'Do something with the array here
'Send the array back to different cells in the spreadsheet
xlSheet.Range(x lSheet.Cells(30 , 30), _
xlSheet.Cells(3 0, 39)).Value = x
I *really* appreciate any help you can give me.
Thanks,
Lee 5 4498
Hi Lee
I think your problem is that in Excel, only variants can
read data from sheets like this, ie
Dim x(9) as Variant
Of course, there is no variant type in VB.Net, but maybe
if you try
Dim x(9) as Object
it will work...
dermot -----Original Message----- Hi All, My problem is trying to figure out how to get the
numbersfrom a range of cells in Excel into an array (double) in
aVB.NET program, do something with the array, and then
sendit back to the spreadsheet. I AM able to open an
exitingExcel spreadsheet and do this with a single cell but not an array. In addition, I can send an array from the VB.NET program to a range of cells in Excel but I can't for the life of me figure out how to get the numbers
froma range of cells in Excel into an array in the VB.NET program. I'm sure it would be easy to use a loop and bring in one cell at a time but my range of cells is
verylarge and it would be very time consuming to do it that way. I'd like to learn how to work with arrays.
Here is a small example of the code I tried that seems like it should work but it doesn't:
Dim x(9) as Double 'Read in the values of a range of cells x = xlSheet.Range(x lSheet.Cells(50 , 10), _ xlSheet.Cells( 50, 19)).Value 'Do something with the array here 'Send the array back to different cells in the
spreadsheet xlSheet.Range(x lSheet.Cells(30 , 30), _ xlSheet.Cells( 30, 39)).Value = x
I *really* appreciate any help you can give me. Thanks, Lee
.
Hi dermot,
Okay, so the data type is the problem here. I tried your
suggestion about dimensioning my array and an Object but
that didn't work either.
-Lee -----Original Message----- Hi Lee
I think your problem is that in Excel, only variants can read data from sheets like this, ie Dim x(9) as Variant
Of course, there is no variant type in VB.Net, but maybe if you try Dim x(9) as Object it will work...
dermot -----Original Message----- Hi All, My problem is trying to figure out how to get thenumbersfrom a range of cells in Excel into an array (double)
inaVB.NET program, do something with the array, and then sendit back to the spreadsheet. I AM able to open an exitingExcel spreadsheet and do this with a single cell but
notan array. In addition, I can send an array from the VB.NET program to a range of cells in Excel but I can't for the life of me figure out how to get the numbers froma range of cells in Excel into an array in the VB.NET program. I'm sure it would be easy to use a loop and bring in one cell at a time but my range of cells is verylarge and it would be very time consuming to do it that way. I'd like to learn how to work with arrays.
Here is a small example of the code I tried that seems like it should work but it doesn't:
Dim x(9) as Double 'Read in the values of a range of cells x = xlSheet.Range(x lSheet.Cells(50 , 10), _ xlSheet.Cells (50, 19)).Value 'Do something with the array here 'Send the array back to different cells in the spreadsheet xlSheet.Range(x lSheet.Cells(30 , 30), _ xlSheet.Cells (30, 39)).Value = x
I *really* appreciate any help you can give me. Thanks, Lee
. .
"Lee" <le********@lum ileds.com> schrieb Hi dermot, Okay, so the data type is the problem here. I tried your suggestion about dimensioning my array and an Object but that didn't work either.
I'd use
dim o as object
o = xlSheet.Range(x lSheet.Cells(50 , 10), xlSheet.Cells(5 0, 19)).Value
and examine o after the assignment to find out the type(s) of the returned
object(s).
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
This worked for me:
Dim x As System.Array
'Read in the values of a range of cells
x = CType(xlSheet.R ange(xlSheet.Ce lls(50, 10), _
xlSheet.Cells(5 0, 19)).Value, System.Array)
'Do something with the array here
'Send the array back to different cells in the spreadsheet
xlSheet.Range(x lSheet.Cells(30 , 30), _
xlSheet.Cells(3 0, 39)).Value = x
--
"Lee" <le********@lum ileds.com> wrote in message news:<05******* *************** ******@phx.gbl> ... Hi dermot, Okay, so the data type is the problem here. I tried your suggestion about dimensioning my array and an Object but that didn't work either. -Lee-----Original Message----- Hi Lee
I think your problem is that in Excel, only variants can read data from sheets like this, ie Dim x(9) as Variant
Of course, there is no variant type in VB.Net, but maybe if you try Dim x(9) as Object it will work...
dermot -----Original Message----- Hi All, My problem is trying to figure out how to get the numbersfrom a range of cells in Excel into an array (double) in aVB.NET program, do something with the array, and then sendit back to the spreadsheet. I AM able to open an exitingExcel spreadsheet and do this with a single cell but notan array. In addition, I can send an array from the VB.NET program to a range of cells in Excel but I can't for the life of me figure out how to get the numbers froma range of cells in Excel into an array in the VB.NET program. I'm sure it would be easy to use a loop and bring in one cell at a time but my range of cells is verylarge and it would be very time consuming to do it that way. I'd like to learn how to work with arrays.
Here is a small example of the code I tried that seems like it should work but it doesn't:
Dim x(9) as Double 'Read in the values of a range of cells x = xlSheet.Range(x lSheet.Cells(50 , 10), _ xlSheet.Cells (50, 19)).Value 'Do something with the array here 'Send the array back to different cells in the spreadsheet xlSheet.Range(x lSheet.Cells(30 , 30), _ xlSheet.Cells (30, 39)).Value = x
I *really* appreciate any help you can give me. Thanks, Lee
. .
BINGO!! That did it! Thanks a million for all the help.
-Lee -----Original Message----- This worked for me:
Dim x As System.Array 'Read in the values of a range of cells x = CType(xlSheet.R ange(xlSheet.Ce lls(50, 10), _ xlSheet.Cells(5 0, 19)).Value, System.Array) 'Do something with the array here 'Send the array back to different cells in the
spreadsheet xlSheet.Range(x lSheet.Cells(30 , 30), _ xlSheet.Cells(3 0, 39)).Value = x
--
"Lee" <le********@lum ileds.com> wrote in message
news:<05******* *************** ******@phx.gbl> ... Hi dermot, Okay, so the data type is the problem here. I tried
your suggestion about dimensioning my array and an Object
but that didn't work either. -Lee >-----Original Message----- >Hi Lee > >I think your problem is that in Excel, only variants
can >read data from sheets like this, ie >Dim x(9) as Variant > >Of course, there is no variant type in VB.Net, but
maybe >if you try >Dim x(9) as Object >it will work... > >dermot > > > >>-----Original Message----- >>Hi All, >>My problem is trying to figure out how to get the numbers >>from a range of cells in Excel into an array
(double) in a >>VB.NET program, do something with the array, and
then send >>it back to the spreadsheet. I AM able to open an exiting >>Excel spreadsheet and do this with a single cell but not >>an array. In addition, I can send an array from the >>VB.NET program to a range of cells in Excel but I
can't >>for the life of me figure out how to get the numbers from >>a range of cells in Excel into an array in the
VB.NET >>program. I'm sure it would be easy to use a loop
and >>bring in one cell at a time but my range of cells is very >>large and it would be very time consuming to do it
that >>way. I'd like to learn how to work with arrays. >> >>Here is a small example of the code I tried that
seems >>like it should work but it doesn't: >> >>Dim x(9) as Double >>'Read in the values of a range of cells >> x = xlSheet.Range(x lSheet.Cells(50 , 10), _ >>xlSheet.Cells (50, 19)).Value >>'Do something with the array here >>'Send the array back to different cells in the spreadsheet >> xlSheet.Range(x lSheet.Cells(30 , 30), _ >>xlSheet.Cells (30, 39)).Value = x >> >>I *really* appreciate any help you can give me. >>Thanks, >>Lee >> >>. >> >. > . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew V. Romero |
last post by:
At work we have an excel file that contains the list of medications and
their corresponding strengths. I would like to save the excel file as a
text list and paste this list into a javascript function and have JS put
this into an array. Then JS would use this array to create a selection
list which displays only the names of the drugs. When the user
selections one of the drugs, another selection list will be loaded with
the avaiable...
|
by: PeteCresswell |
last post by:
I've been to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mschrt/html/vbobjtitleobject.asp,
but still don't have a clue.
For example, I've got a chart object namde 'grphStats' in a form named
frmChart.
?Forms!frmChart!grphStats.Name returns "grphStats" as expected, but
I can't get any further.
|
by: George |
last post by:
Is there a fast way to transfer an Excel range to an array?
Example:
Excel range is E2:E300
Dim person() as string
Thanks,
George
|
by: KH Tay |
last post by:
Hi,
I can able to run the Excel Macro command in VB6. Unfortunately , VB.Net
always prompt Array - no declaring. I've insert the Excel references, and it
is still not working. Can anyone help me ? Thanks.
Source code:-
xl.Workbooks.OpenText(Filename:="C:\SMT\SMT.TXT",
Origin:=Excel.XlPlatform.xlWindows, StartRow _
:=1, DataType:=Excel.XlTextParsingType.xlDelimited,
TextQualifier:=Excel.XlTextQualifier.xlTextQualifierNone,
|
by: DWalker |
last post by:
VBA, as used in Excel 2000 and Excel 2003, has a function called Array.
It's commonly seen in statements like the following:
Workbooks.OpenText Filename:=ACFileName, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), _
Array(9, 1), Array(18, 1), Array(33, 1), Array(49, 1), Array(71, 1), _
Array(75, 1), Array(89, 1), Array(113, 1), Array(117, 1), Array(135, 1))
The FieldInfo parameter is an array of arrays, and the...
| |
by: michealmess |
last post by:
Can anyone help me. I wish to export an array from vb.net to excel
ranges. This will happen for multiple files. The ranges names will not
be start and end in the same cells on all files. How do i do this?
|
by: blainegray |
last post by:
Greetings
This is one of those Access is not closing Excel problems.
The first time through the code works fine. The second time there is a problem.
After lots of combinations, I finally determined that if I take out the line that copies the temp array to cells in a worksheet, Access will close the Excel file. If the line is there, Excel remains open and blocks more runs of the same procedure. If I close Access, Excel gets closed. Looks like...
|
by: gellis72 |
last post by:
I'm working on a program that imports a bunch of data from a folder
full of Excel files and compiles it into an Access DB. The Excel files
have a varying number of rows and columns that need to be imported,
and the data needs to be processed/error checked before it's written
to the DB. The way I've tackled this is to have a procedure that steps
through a list of Excel files, invokes an instance of Excel, opens
file "x", copies the relevant...
|
by: =?Utf-8?B?S3VuIE5pdQ==?= |
last post by:
Dear all,
I'm trying to use oledb to get the content of an excel file.
Now I can use oledb to get the content of a datasheet.
But I should know the name of the datasheet in advance.
How can I use oledb to query the names of all the spreadsheets in the excel
file?
Thanks in advance for any hints and reply.
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |