tags:

views:

83

answers:

2

It is possible to write a code that specifying the rows and column of spread sheet in terms of NUMBERS and NOT LIKE (B2:D6)

Example:

excelSheet.Range("B2:D6").Interior.Color = RGB(100, 100, 255)

instead of B2 and D6 I want to write 5 rows and 3 column..

It is posible to write in vb.net 2003 code?

+2  A: 

This is C# and not VB, but this shouldn't be too hard to convert:

var firstCell = (Excel.Range)sheet.Cells[3, 3];
var secondCell = (Excel.Range)sheet.Cells[5, 7];
var cells = sheet.get_Range(firstCell, secondCell);
Mathias
thanks for this reponse..may i know how to have a border in all cells from A1 to E10..and also, it is allowable to do this?excelSheet.Cells(1, 10).BorderAround()
Mark
Mark, yes I have a fairly good idea how to do this, but I also see that you have asked 14 questions, but you haven't accepted a single answer on on any of them. You have to understand that this isn't very motivating.
Mathias
A: 

Just use Cells() instead of Range()

excelSheet.Cells(5,3).Interior.Color = RGB(100, 100, 255)
BradC
What is the code for having a border in all cells from A1:E5
Mark
@Mark - The easiest way to find the answer to questions like that is to record a macro, perform the action, then see what code it recorded. In the case of borders, you end up with a long series of statements that look something like ".Borders(xlEdgeTop).LineStyle = xlContinuous"
BradC