Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Loop until cell is empty

Hi JLatham and other Experts,
I'm almost there. How do you improve this code so that the msgbox pops
up only when the activecell is not empty (which it does now) and only
when the activecell is not the s2 String? Presently, it asks to replace
the title when the activecell is already = s2.

Sub OtherOperatingExpense()
Dim s1 As String, s2 As String
s1 = "total operating expenses"
s2 = "Other Expense"

Cells.Find(What:=s1, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
ActiveCell.Offset(-2, 0).Range("A1").Select

Do While LCase(ActiveCell) = LCase(s2)
ActiveCell.Offset(-1, 0).Range("A1").Select
Loop

Do While ActiveCell < Empty
If MsgBox("[" & ActiveCell & "]" & " will be replaced with " & "[" &
s2 & "]", vbYesNo, _
"Updating Other Titles Changes") = vbYes Then
ActiveCell = s2
End If
ActiveCell.Offset(-1, 0).Range("A1").Select
Loop
End Sub

Thanks in advance,
Ricky


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default Loop until cell is empty

Try

Do ActiveCell < Empty AND ActiveCell < s2

"Ricky Pang" wrote:

Hi JLatham and other Experts,
I'm almost there. How do you improve this code so that the msgbox pops
up only when the activecell is not empty (which it does now) and only
when the activecell is not the s2 String? Presently, it asks to replace
the title when the activecell is already = s2.

Sub OtherOperatingExpense()
Dim s1 As String, s2 As String
s1 = "total operating expenses"
s2 = "Other Expense"

Cells.Find(What:=s1, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
ActiveCell.Offset(-2, 0).Range("A1").Select

Do While LCase(ActiveCell) = LCase(s2)
ActiveCell.Offset(-1, 0).Range("A1").Select
Loop

Do While ActiveCell < Empty
If MsgBox("[" & ActiveCell & "]" & " will be replaced with " & "[" &
s2 & "]", vbYesNo, _
"Updating Other Titles Changes") = vbYes Then
ActiveCell = s2
End If
ActiveCell.Offset(-1, 0).Range("A1").Select
Loop
End Sub

Thanks in advance,
Ricky


*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Loop until cell is empty

Hi JLatham,
I've tried your suggestion. If someone made changes within those cells,
this code would jump only to the first cell that < s2, make the change,
then it stops. I'm trying to get the code to continue jumping up to the
next < s2 cell and keep making more changes. Any ideas?

Thanks in advance,
Ricky


*** Sent via Developersdex http://www.developersdex.com ***
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 to find next empty cell to the right not working. Casey[_84_] Excel Programming 3 May 4th 06 03:16 PM
Finding next empty empty cell in a range of columns UncleBun Excel Programming 1 January 13th 06 11:22 PM
having probelms getting my loop to terminate on an array value read from an empty cell mizcrab Excel Programming 3 November 30th 05 02:54 AM
Loop all sheetsand delete empty rows Sige Excel Programming 2 July 27th 05 12:22 PM
Empty cells in For Loop Linking to specific cells in pivot table Excel Programming 2 May 16th 05 07:25 PM


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