Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Loop and delete

I have the following code to loop through the cells in AZ:

Dim myRange As Range
Dim myCell As Range

With ActiveSheet
Set myRange = Range("AZ14:AZ33")
End With

For Each myCell In myRange.Cells
If myCell.Value = lstObj.Text Then
myCell.Value = ""

'Here I want to delete the values in cell J to BB!!!
End If
Next myCell

Now it deletes the values in myCell but I want to change this to delete
the values in the cells J to BB. How can this be done?

I'm very grateful for fast response.

Regards,

S

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Loop and delete

Hi,

ActiveCell.Offset(0, -42).Range("A1:AS1").ClearContents

HTH
Carim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Loop and delete

S,

Cells(myCell.Row,"J").Resize(1,19).ClearContents

Or

Range(Cells(myCell.Row,"J"), Cells(myCell.Row,"BB")).ClearContents

HTH,
Bernie
MS Excel MVP


wrote in message ups.com...
I have the following code to loop through the cells in AZ:

Dim myRange As Range
Dim myCell As Range

With ActiveSheet
Set myRange = Range("AZ14:AZ33")
End With

For Each myCell In myRange.Cells
If myCell.Value = lstObj.Text Then
myCell.Value = ""

'Here I want to delete the values in cell J to BB!!!
End If
Next myCell

Now it deletes the values in myCell but I want to change this to delete
the values in the cells J to BB. How can this be done?

I'm very grateful for fast response.

Regards,

S



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Loop and delete

Oops, I counted to AB, not BB:

Cells(myCell.Row,"J").Resize(1,45).ClearContents

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
S,

Cells(myCell.Row,"J").Resize(1,19).ClearContents

Or

Range(Cells(myCell.Row,"J"), Cells(myCell.Row,"BB")).ClearContents

HTH,
Bernie
MS Excel MVP


wrote in message ups.com...
I have the following code to loop through the cells in AZ:

Dim myRange As Range
Dim myCell As Range

With ActiveSheet
Set myRange = Range("AZ14:AZ33")
End With

For Each myCell In myRange.Cells
If myCell.Value = lstObj.Text Then
myCell.Value = ""

'Here I want to delete the values in cell J to BB!!!
End If
Next myCell

Now it deletes the values in myCell but I want to change this to delete
the values in the cells J to BB. How can this be done?

I'm very grateful for fast response.

Regards,

S





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Loop and delete

Thank's a lot Bernie! Your solution is great.

Regards,

S

Bernie Deitrick skrev:

Oops, I counted to AB, not BB:

Cells(myCell.Row,"J").Resize(1,45).ClearContents

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
S,

Cells(myCell.Row,"J").Resize(1,19).ClearContents

Or

Range(Cells(myCell.Row,"J"), Cells(myCell.Row,"BB")).ClearContents

HTH,
Bernie
MS Excel MVP


wrote in message ups.com...
I have the following code to loop through the cells in AZ:

Dim myRange As Range
Dim myCell As Range

With ActiveSheet
Set myRange = Range("AZ14:AZ33")
End With

For Each myCell In myRange.Cells
If myCell.Value = lstObj.Text Then
myCell.Value = ""

'Here I want to delete the values in cell J to BB!!!
End If
Next myCell

Now it deletes the values in myCell but I want to change this to delete
the values in the cells J to BB. How can this be done?

I'm very grateful for fast response.

Regards,

S




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
Loop & Delete Jenna Excel Discussion (Misc queries) 3 January 24th 07 06:34 PM
find, delete, repeat loop [email protected] Excel Programming 2 July 18th 06 07:21 PM
loop and delete Peterke Excel Programming 3 March 29th 06 06:02 AM
A loop to delete Nikki Excel Programming 1 December 3rd 04 07:59 PM
loop to delete rows... Froglegz Excel Programming 5 August 1st 04 09:56 PM


All times are GMT +1. The time now is 09:08 PM.

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

About Us

"It's about Microsoft Excel"