ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming Range Variables (https://www.excelbanter.com/excel-programming/320312-naming-range-variables.html)

Scott

Naming Range Variables
 
If I want to pass the variable iRefStart to the DeleteCells() Function, what
syntax is needed? Below, I'm just trying to say"Start at Cell B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")



Gary Brown[_5_]

Naming Range Variables
 
The only thing I would add is...
Dim iRefStart As String
HTH,
Gary Brown


"scott" wrote:

If I want to pass the variable iRefStart to the DeleteCells() Function, what
syntax is needed? Below, I'm just trying to say"Start at Cell B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")




Jim Thomlinson[_3_]

Naming Range Variables
 
Your function does not indicate that it has a return value. Is that an
oversight or is it not really a function? As it stands it is a sub...

"scott" wrote:

If I want to pass the variable iRefStart to the DeleteCells() Function, what
syntax is needed? Below, I'm just trying to say"Start at Cell B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")




Scott

Naming Range Variables
 
I'm just trying to pass "B" to the Function and allow the function to
concatenate the "B" with a "1" to set the begin cell. Can you help me
rewrite it or point out why it won't work?

The function works fine hard coded with Set rng = Range("B1:B10")



"Jim Thomlinson" wrote in message
...
Your function does not indicate that it has a return value. Is that an
oversight or is it not really a function? As it stands it is a sub...

"scott" wrote:

If I want to pass the variable iRefStart to the DeleteCells() Function,
what
syntax is needed? Below, I'm just trying to say"Start at Cell B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")






Chip Pearson

Naming Range Variables
 
Your code works fine for me. What problem are you having? What
exact error message do you receive on what line of code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"scott" wrote in message
...
I'm just trying to pass "B" to the Function and allow the
function to concatenate the "B" with a "1" to set the begin
cell. Can you help me rewrite it or point out why it won't
work?

The function works fine hard coded with Set rng =
Range("B1:B10")



"Jim Thomlinson"
wrote in message
...
Your function does not indicate that it has a return value. Is
that an
oversight or is it not really a function? As it stands it is a
sub...

"scott" wrote:

If I want to pass the variable iRefStart to the DeleteCells()
Function, what
syntax is needed? Below, I'm just trying to say"Start at Cell
B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")








Scott

Naming Range Variables
 
no error, my code that takes action doesn't fire when using the variable for
"B"


"Chip Pearson" wrote in message
...
Your code works fine for me. What problem are you having? What exact
error message do you receive on what line of code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"scott" wrote in message
...
I'm just trying to pass "B" to the Function and allow the function to
concatenate the "B" with a "1" to set the begin cell. Can you help me
rewrite it or point out why it won't work?

The function works fine hard coded with Set rng = Range("B1:B10")



"Jim Thomlinson" wrote in
message ...
Your function does not indicate that it has a return value. Is that an
oversight or is it not really a function? As it stands it is a sub...

"scott" wrote:

If I want to pass the variable iRefStart to the DeleteCells() Function,
what
syntax is needed? Below, I'm just trying to say"Start at Cell B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")










Scott

Naming Range Variables
 
it works now. thanks.

"Chip Pearson" wrote in message
...
Your code works fine for me. What problem are you having? What exact
error message do you receive on what line of code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"scott" wrote in message
...
I'm just trying to pass "B" to the Function and allow the function to
concatenate the "B" with a "1" to set the begin cell. Can you help me
rewrite it or point out why it won't work?

The function works fine hard coded with Set rng = Range("B1:B10")



"Jim Thomlinson" wrote in
message ...
Your function does not indicate that it has a return value. Is that an
oversight or is it not really a function? As it stands it is a sub...

"scott" wrote:

If I want to pass the variable iRefStart to the DeleteCells() Function,
what
syntax is needed? Below, I'm just trying to say"Start at Cell B1"

Sub CleanSpreed()
iRefStart = "B"
Call DeleteCells(iRefStart)

Function DeleteCells(ByVal iRefStart As String)

Dim rng As Range

Set rng = Range(iRefStart & "1:B10")











All times are GMT +1. The time now is 08:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com