i can get a single value from a worksheet using vb.net and excel.
q)How do i get a range of values eg A2 to A5 and print them out eg with a msgbox. I know i can use the cells command but i want a range command where specify excel cell range.
'MyString = XL.Cells(4, 1).Value
MyString = XL.Range("A2", "A5").Value 'error
MsgBox(MyString)
11 1309
Hi,
I Guess, Return Range should be assigned to an Array:
Try This :
Dim MyArr() As String
MyArr = XL.Range("A2:A5").Value
And Loop through MyArr, to get all the Values..
Regards
Veena
Hi,
I Guess, Return Range should be assigned to an Array:
Try This :
Dim MyArr() As String
MyArr = XL.Range("A2:A5").Value
And Loop through MyArr, to get all the Values..
Regards
Veena
It wont work all the times for Strings array, try using a variant. The nice thing about asigning a Range to a Variant, is that the variant wont change into a Variant/Range, but into a Variant's array.
so
dim MyArr
MyArr = Range("A2:A5")
will make MyArr a 2 dimensioned array (1 to 4, 1 to 1) of variants, which index start in 1.
HTH
dim MyArr
MyArr = Range("A2:A5")
will make MyArr a 2 dimensioned array (1 to 4, 1 to 1) of variants, which index start in 1.
That's weird. It seems pretty silly of it to create a two-dimensional array, don't you think? Then again, computers do work in mysterious ways.
That's weird. It seems pretty silly of it to create a two-dimensional array, don't you think? Then again, computers do work in mysterious ways.
No, its quite useful when working with Excel's VBA, because you can use the same FOR for a range an its array. Also you can asign an 2 dimensioned array to a range, so it'll be writen in the worksheet. e.g.
range("A3,A5") = Arr
=) Where Arr is a 2 dimension array (1 to 3, 1 to 1)
I asked this before but i still dont know
can i set a range of values from excel to a datagrid?
I asked this before but i still dont know
can i set a range of values from excel to a datagrid?
can you asign an Array to a datagrid?
i can assign a 1D array to a datagrid yes.
i cant assign a 2d array so i need to convert the 2d array to 1D array but i cant get rows and cols in a datagrid with rows and cols (just 1 col).
This is very complicated!
i can assign a 1D array to a datagrid yes.
i cant assign a 2d array so i need to convert the 2d array to 1D array but i cant get rows and cols in a datagrid with rows and cols (just 1 col).
This is very complicated!
- dim a
-
dim b()
-
dim i as long
-
a = range("a2:a5")
-
redim b(1 to ubound(a))
-
for i = 1 to ubound(a)
-
b(i) = a(i,1)
-
next
And now b is your 1D array.
^.^
i have a range "A2:B5" but i can convert to array.
the problme is assigning to a datagrid
datagrid1.datasource= myarray ' myarray is single array from 2D array
'the datagrid is just 1 col and i want rows and cols like the 2D array origanlly is.
it is messy
i have a range "A2:B5" but i can convert to array.
the problme is assigning to a datagrid
datagrid1.datasource= myarray ' myarray is single array from 2D array
'the datagrid is just 1 col and i want rows and cols like the 2D array origanlly is.
it is messy
in my last post, 'a' is a 2D array, and then 'b' is the 1D array that you may use.
i have used a datatable which is more effective. the trick is to fill data from excel2d array and copy to datatable.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Follower |
last post by:
Hi,
I am working on a function to return extracts from a text document
with a specific phrase highlighted (i.e. display the context of the
matched phrase).
The requirements are:
* Match...
|
by: Dan R Brown |
last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to
break up this form into several "tabbed" sections, I break up the form using <div>
tags. Each <div...
|
by: denis |
last post by:
Please help
Here is my code. I was able to modified to go to main menu.
But If user enter a value outside the range it should not
go to the main menu. It should display only:
cout<<"Please enter...
|
by: heri |
last post by:
Can you please assist me on how to get the 2nd record in case there are
3 or more records of an employee, the query below gets the MAX and MIN
BasicSalary. However, my MIN Basic Salary is wrong...
|
by: John Phelan-Cummings |
last post by:
When I add the name of a new individual in a, bound form, it will not
display that person’s name in a label control of a second unbound form.
I have a scheduling program that I am working on. ...
|
by: crist135 |
last post by:
Hi guys,
I have successfully done the retrieving of PDF file from Sql Server BLOB. Though, some of the pdf files are displaying it nicely but in some, postscript is being displayed. I am using...
|
by: adubra |
last post by:
Hi there,
I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
|
by: aravicha |
last post by:
Hi ,
i want a sample perl code to display all the dates between a date range.
say, the start_date=18/03/2007 and end_date=18/04/2007.
here i want to print all the dates beween 18/03/2007 &...
|
by: iftekar14 |
last post by:
i have to create this at VB express 2008
When the user clicks the Process Files button, do the following:
Read and process the contents of each of the 6 files.
Each file contains data in a...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |