Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Ranges using offset

Let's say I have the following to delete the contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named range -
say "last_column" which is the number 67. How would I
change the above code to referenc the number in the range
vs manually edititing the code? Looking for same help
with row (say "last_row" = 100)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Ranges using offset

Fatir,

Try this

'-----
Option Explicit

Sub abc()
With Range("lastColumn")
.Offset(0, 1).Resize(Rows.Count, (Columns.Count - .Column)).Delete
End With
End Sub
'-----

HTH
Anders Silven

"Fatir Zelen" skrev i meddelandet
...
Let's say I have the following to delete the contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named range -
say "last_column" which is the number 67. How would I
change the above code to referenc the number in the range
vs manually edititing the code? Looking for same help
with row (say "last_row" = 100)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Ranges using offset

Got a compile error at the .Column)) part - didn't use
option explicit or sub since inside existing code but I
dont think that should matter.

Was that a typo Bob?
-----Original Message-----
Fatir,

Try this

'-----
Option Explicit

Sub abc()
With Range("lastColumn")
.Offset(0, 1).Resize(Rows.Count, (Columns.Count -

.Column)).Delete
End With
End Sub
'-----

HTH
Anders Silven

"Fatir Zelen" skrev

i meddelandet
...
Let's say I have the following to delete the contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named

range -
say "last_column" which is the number 67. How would I
change the above code to referenc the number in the

range
vs manually edititing the code? Looking for same help
with row (say "last_row" = 100)



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Ranges using offset

No typo, and I'm not Bob.

It looks like a line break has been inserted somewhere along the line.
".Column)).Delete" belongs to the line above it.

Try the macro by itself to make sure it works before you enter it into your
existing code

Regards
Anders Silven


"Fatir Zelen" skrev i meddelandet
...
Got a compile error at the .Column)) part - didn't use
option explicit or sub since inside existing code but I
dont think that should matter.

Was that a typo Bob?
-----Original Message-----
Fatir,

Try this

'-----
Option Explicit

Sub abc()
With Range("lastColumn")
.Offset(0, 1).Resize(Rows.Count, (Columns.Count -

.Column)).Delete
End With
End Sub
'-----

HTH
Anders Silven

"Fatir Zelen" skrev

i meddelandet
...
Let's say I have the following to delete the contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named

range -
say "last_column" which is the number 67. How would I
change the above code to referenc the number in the

range
vs manually edititing the code? Looking for same help
with row (say "last_row" = 100)



.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Ranges using offset

Sorry the name error.

Here is what I have and it still doesn't work, even on its
own.

Sub remove_blanks()
Sheets("Main").Select
With Range("End_Col")
.Offset(0, 1).Resize(Rows.Count, (Columns.Count -
.Column)).Delete (this is actually in the live above)
End With
End Sub

End_Col is the named range with a value of 66 so it would
delete columns 67-256


Any sugggestions??

-----Original Message-----
No typo, and I'm not Bob.

It looks like a line break has been inserted somewhere

along the line.
".Column)).Delete" belongs to the line above it.

Try the macro by itself to make sure it works before you

enter it into your
existing code

Regards
Anders Silven


"Fatir Zelen" skrev

i meddelandet
...
Got a compile error at the .Column)) part - didn't use
option explicit or sub since inside existing code but I
dont think that should matter.

Was that a typo Bob?
-----Original Message-----
Fatir,

Try this

'-----
Option Explicit

Sub abc()
With Range("lastColumn")
.Offset(0, 1).Resize(Rows.Count,

(Columns.Count -
.Column)).Delete
End With
End Sub
'-----

HTH
Anders Silven

"Fatir Zelen"

skrev
i meddelandet
...
Let's say I have the following to delete the

contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named

range -
say "last_column" which is the number 67. How would

I
change the above code to referenc the number in the

range
vs manually edititing the code? Looking for same

help
with row (say "last_row" = 100)



.


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Ranges using offset

Firts you have a hyphen instead of a continuation caharacter. An, if end_col
is 66 it is not a named range as a range -s C6 or C6:C100. You might try
this

Sub remove_blanks()
Sheets("Main").Select
With Range("C" &End_Col)
.Offset(0, 1).Resize(Rows.Count, (Columns.Count _
.Column)).Delete (this is actually in the live above)
End With
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Fatir Zelen" wrote in message
...
Sorry the name error.

Here is what I have and it still doesn't work, even on its
own.

Sub remove_blanks()
Sheets("Main").Select
With Range("End_Col")
.Offset(0, 1).Resize(Rows.Count, (Columns.Count -
.Column)).Delete (this is actually in the live above)
End With
End Sub

End_Col is the named range with a value of 66 so it would
delete columns 67-256


Any sugggestions??

-----Original Message-----
No typo, and I'm not Bob.

It looks like a line break has been inserted somewhere

along the line.
".Column)).Delete" belongs to the line above it.

Try the macro by itself to make sure it works before you

enter it into your
existing code

Regards
Anders Silven


"Fatir Zelen" skrev

i meddelandet
...
Got a compile error at the .Column)) part - didn't use
option explicit or sub since inside existing code but I
dont think that should matter.

Was that a typo Bob?
-----Original Message-----
Fatir,

Try this

'-----
Option Explicit

Sub abc()
With Range("lastColumn")
.Offset(0, 1).Resize(Rows.Count,

(Columns.Count -
.Column)).Delete
End With
End Sub
'-----

HTH
Anders Silven

"Fatir Zelen"

skrev
i meddelandet
...
Let's say I have the following to delete the

contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named
range -
say "last_column" which is the number 67. How would

I
change the above code to referenc the number in the
range
vs manually edititing the code? Looking for same

help
with row (say "last_row" = 100)



.


.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Ranges using offset

Do you mean firts_row and last_row?

Sheets("Main").Select
Application.GoTo Reference:="C" & first_row & ":C25" & last_row
Selection.Delete Shift:=xlToLeft


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Fatir Zelen" wrote in message
...
Let's say I have the following to delete the contents of
Column 68 to 256.

Sheets("Main").Select
Application.GoTo Reference:="C68:C256"
Selection.Delete Shift:=xlToLeft

but instead I want the reference to be from a named range -
say "last_column" which is the number 67. How would I
change the above code to referenc the number in the range
vs manually edititing the code? Looking for same help
with row (say "last_row" = 100)




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use OFFSET and COUNT functions within Named Ranges [email protected] Excel Discussion (Misc queries) 2 October 26th 06 04:01 AM
Dynamic Ranges and Offset RFJ Excel Worksheet Functions 3 August 29th 06 03:20 PM
Offset function and Dynamic Ranges SandyLACA Excel Discussion (Misc queries) 2 August 2nd 06 11:07 PM
Using Offset with named ranges StanJ Excel Worksheet Functions 5 September 2nd 05 09:07 AM
returning ranges offset from argument range function call Peter Williams Excel Programming 5 February 8th 04 11:59 PM


All times are GMT +1. The time now is 03:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"