Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default If/then statement for text string

I need a macro that will loop until the last empty cell in column B

This what I need:

If the cells in column "B" contains the word "Total", then copy the cells in
Column "D" to column "E"

This is what I have so far but it is not working. Please help

Sub Copy_subtotal()

Dim i As Integer


i = 4

Do Until IsEmpty(Cells(i, 2))
If Cells(i, 2).Formula = "=RIGHT(RC,5))" = "Total" Then
Cells(i, 4).Copy
Cells(i, 6).Paste

End If

i = i + 1
Loop

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default If/then statement for text string

Maybe...

Option Explicit
Sub Copy_subtotal2()

Dim i As Long
i = 4

Do Until IsEmpty(Cells(i, 2))
If LCase(Left(Cells(i, 2).Value, 5)) = LCase("total") Then
Cells(i, 4).Copy _
Destination:=Cells(i, 6)
End If
i = i + 1
Loop

End Sub



David T wrote:

I need a macro that will loop until the last empty cell in column B

This what I need:

If the cells in column "B" contains the word "Total", then copy the cells in
Column "D" to column "E"

This is what I have so far but it is not working. Please help

Sub Copy_subtotal()

Dim i As Integer

i = 4

Do Until IsEmpty(Cells(i, 2))
If Cells(i, 2).Formula = "=RIGHT(RC,5))" = "Total" Then
Cells(i, 4).Copy
Cells(i, 6).Paste

End If

i = i + 1
Loop

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default If/then statement for text string

Dave-

You are the man!!! It works perfect. The only thing i changed in the
formula was from "Left" to "Right" so that it takes the last five letters of
that cell.

Thanks!!!!!!!1

"Dave Peterson" wrote:

Maybe...

Option Explicit
Sub Copy_subtotal2()

Dim i As Long
i = 4

Do Until IsEmpty(Cells(i, 2))
If LCase(Left(Cells(i, 2).Value, 5)) = LCase("total") Then
Cells(i, 4).Copy _
Destination:=Cells(i, 6)
End If
i = i + 1
Loop

End Sub



David T wrote:

I need a macro that will loop until the last empty cell in column B

This what I need:

If the cells in column "B" contains the word "Total", then copy the cells in
Column "D" to column "E"

This is what I have so far but it is not working. Please help

Sub Copy_subtotal()

Dim i As Integer

i = 4

Do Until IsEmpty(Cells(i, 2))
If Cells(i, 2).Formula = "=RIGHT(RC,5))" = "Total" Then
Cells(i, 4).Copy
Cells(i, 6).Paste

End If

i = i + 1
Loop

End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default If/then statement for text string

Right, left. It all depends on which side of the monitor you're on! <vbg.

Glad you got it working.

David T wrote:

Dave-

You are the man!!! It works perfect. The only thing i changed in the
formula was from "Left" to "Right" so that it takes the last five letters of
that cell.

Thanks!!!!!!!1

"Dave Peterson" wrote:

Maybe...

Option Explicit
Sub Copy_subtotal2()

Dim i As Long
i = 4

Do Until IsEmpty(Cells(i, 2))
If LCase(Left(Cells(i, 2).Value, 5)) = LCase("total") Then
Cells(i, 4).Copy _
Destination:=Cells(i, 6)
End If
i = i + 1
Loop

End Sub



David T wrote:

I need a macro that will loop until the last empty cell in column B

This what I need:

If the cells in column "B" contains the word "Total", then copy the cells in
Column "D" to column "E"

This is what I have so far but it is not working. Please help

Sub Copy_subtotal()

Dim i As Integer

i = 4

Do Until IsEmpty(Cells(i, 2))
If Cells(i, 2).Formula = "=RIGHT(RC,5))" = "Total" Then
Cells(i, 4).Copy
Cells(i, 6).Paste

End If

i = i + 1
Loop

End Sub


--

Dave Peterson


--

Dave Peterson
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
Returning a string of values in an IF statement Dave F Excel Discussion (Misc queries) 1 January 11th 07 01:33 AM
Can I create an IF statement that looks for part of a string of te Josh Craig Excel Worksheet Functions 2 June 19th 06 08:23 AM
LOOKUP a text string created from IF statement Steve-in-austin Excel Discussion (Misc queries) 0 May 11th 06 09:10 PM
Splitting a text string into string and number mcambrose Excel Discussion (Misc queries) 4 February 21st 06 03:47 PM
want to remove all text characters equal to one character in length from text string [email protected] Excel Worksheet Functions 1 April 18th 05 09:56 PM


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