using range name VB help

E

Eddy Stan

Hi
dim wb as workbook
Set wb = ActiveWorkbook

- This works....
set sh2 = worksheets("DSOCM")
Set rng = sh2.Range(sh2.Cells(2, 1), sh2.Cells(Rows.Count, 1).End(xlUp))

the above range refers to range name created in workbook called "DSOCMC"
' range DSOCMC is a7:a7000

- BUT, can we not use
Set rng = sh2.names("DSOCMC").ReferToRange (OR)
Set rng = wb.names("DSOCMC").ReferToRange (or)

or any method please................

I want to use range names instead of xlup /xldown, like that
pl help.

Eddy Stan
 
E

eliano

Hi
dim wb as workbook
Set wb = ActiveWorkbook

- This works....
set sh2 = worksheets("DSOCM")
Set rng = sh2.Range(sh2.Cells(2, 1), sh2.Cells(Rows.Count, 1).End(xlUp))

the above range refers to range name created in workbook called "DSOCMC"
' range DSOCMC is a7:a7000

- BUT, can we not use
Set rng = sh2.names("DSOCMC").ReferToRange     (OR)
Set rng = wb.names("DSOCMC").ReferToRange     (or)

or any method please................

I want to use range names instead of xlup /xldown, like that
pl help.

Eddy Stan

Try:
Public Sub prova()
Dim sh2 As Worksheet
Dim rng As Range
Set sh2 = Worksheets("Foglio1")
Set rng = sh2.UsedRange

MsgBox rng.Address

End Sub

Regards
Eliano
 

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