Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default moving to next cell in range

All,

I thought I had this, but....
What I need is to remove the data in cell A1 if in cell D1 it
states;"Would you like to add any comments?"...then move to the next
row/cell until cell A(whatever) contains no data.

Sub Test()
Dim Cell As Range
For Each Cell In Range("D:D")
If Range("D1") = "Would you like to add any comments?" Then
Range("A1") = ""
Next
End Sub


Any help is appreciated

Hans

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default moving to next cell in range

Sub Test()
Dim Cell As Range
For Each Cell In Range("D:D")
If cell = "Would you like to add any comments?" Then
cell.offset(0,-3).ClearContents
End if
Next
End Sub

However, that would take forever

Sub Test
Dim cell as Range, rng as Range
set rng = .Range(cells(1,"D"),cells(rows.count,"D").End(xlup ))
for each cell in rng
If cell = "Would you like to add any comments?" Then
cell.offset(0,-3).ClearContents
end if
Next
End sub

there are other ways, such as using find.

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
All,

I thought I had this, but....
What I need is to remove the data in cell A1 if in cell D1 it
states;"Would you like to add any comments?"...then move to the next
row/cell until cell A(whatever) contains no data.

Sub Test()
Dim Cell As Range
For Each Cell In Range("D:D")
If Range("D1") = "Would you like to add any comments?" Then
Range("A1") = ""
Next
End Sub


Any help is appreciated

Hans



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default moving to next cell in range

Tom,

Thanks for the help; I am new to the VB side...How would you use "find"
in a situation like this?


Thanks,

Hans

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default moving to next cell in range

Look at the VBA help example for FindNext

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
Tom,

Thanks for the help; I am new to the VB side...How would you use "find"
in a situation like this?


Thanks,

Hans



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default moving to next cell in range

Hans,

Try:

Sub Test()
Dim aCell As Range

For Each aCell In Range("D:D")
If aCell = "Would you like to add any comments?" Then
aCell.Offset(0, -3).ClearContents
End If
Next aCell
Set aCell = Nothing
End Sub

HTH

Tim


wrote in message
oups.com...
All,

I thought I had this, but....
What I need is to remove the data in cell A1 if in cell D1 it
states;"Would you like to add any comments?"...then move to the next
row/cell until cell A(whatever) contains no data.

Sub Test()
Dim Cell As Range
For Each Cell In Range("D:D")
If Range("D1") = "Would you like to add any comments?" Then
Range("A1") = ""
Next
End Sub


Any help is appreciated

Hans





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default moving to next cell in range

Gentlemen....thanks for your help, it is working like I need now!

Hans

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
Moving range? wx4usa Excel Discussion (Misc queries) 7 December 26th 09 04:28 PM
Keep cell reference when moving range (matter of urgency) Xtian Excel Worksheet Functions 4 October 4th 07 05:10 PM
sum with moving range snax500 Excel Discussion (Misc queries) 3 July 10th 06 05:56 AM
Moving between a cell that is selected to include a range of cells in that row kls[_2_] Excel Programming 0 September 30th 04 12:14 AM
Moving a range between workbooks Robert[_21_] Excel Programming 2 April 21st 04 04:41 PM


All times are GMT +1. The time now is 06:10 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"