How to reference a named area

O

Orlando

HI, programming in excel VBA, how can I make reference to and area I define,
example I name the area D5 to F10 and I call it Salary, how can I read the
information in the cell D5 or E8 from VBA.

Thanks.
 
O

OssieMac

Hi orlando,

I'm not sure if you are referring to a range which you have named in the
interactive mode or a range to which you have assigned to a variable in VBA.

I suggest that you copy the following code into a blank workbook and check
out what it all does.

Macro1 starts with recorded code of naming a range while working on the
worksheet. The Named range could have been created previously but I have put
it in the macro so that you have the range named properly for the following
code.

Run the macros in order by number.

Macro2 then puts some data in the cells in the named range. Note that the
named range is like a mini worksheet within a worksheet and the cells start
on row1, column 1 of the named range. When using the cells function, note
that the row number is first and the column number second. Cells(RowNumber,
ColumnNumber).
This is opposite to range("A1") where column number is first.

Comments in the other macros say what they do.

I have included code which inserts data, reads data and loops through all
the cells in the range.

Macro5: Lastly, I have included code to assign a range to a VBA variable and
then loop through the cells and write data to them.

Hope this helps and feel free to get back to me if you have any more
questions.

Regards,

OssieMac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top