Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default MyCell. Value = "total"

A wonderful programmer provided me with this code and I would like for
it to work only if the row "contains" the text "total".

This doesn't work unless the cell specifically says "total".

Thanks for your help in advance.


Option Explicit
Dim MyCell, MyRng As Range
Dim i As Integer


Private Sub CommandButton1_Click()
Set MyRng = [a1:a65000] 'set your range
For Each MyCell In MyRng
If MyCell.Value = "total" Then
MyCell.Offset(1, 0).Select
Do While i < 4
ActiveCell.EntireRow.Insert
i = i + 1
Loop
ActiveCell.Value = "Avails"
ActiveCell.EntireRow.Interior.ColorIndex = 5
ActiveCell.Offset(1, 0).Value = "Left"
ActiveCell.Offset(1, 0).EntireRow.Interior.ColorIndex = 6
End If
Next MyCell
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default MyCell. Value = "total"

Hi
Replace the offending bit with
If Instr(MyCell.Value,"total")0 then

regards
Paul

On Mar 20, 3:23 pm, wrote:
A wonderful programmer provided me with this code and I would like for
it to work only if the row "contains" the text "total".

This doesn't work unless the cell specifically says "total".

Thanks for your help in advance.

Option Explicit
Dim MyCell, MyRng As Range
Dim i As Integer

Private Sub CommandButton1_Click()
Set MyRng = [a1:a65000] 'set your range
For Each MyCell In MyRng
If MyCell.Value = "total" Then
MyCell.Offset(1, 0).Select
Do While i < 4
ActiveCell.EntireRow.Insert
i = i + 1
Loop
ActiveCell.Value = "Avails"
ActiveCell.EntireRow.Interior.ColorIndex = 5
ActiveCell.Offset(1, 0).Value = "Left"
ActiveCell.Offset(1, 0).EntireRow.Interior.ColorIndex = 6
End If
Next MyCell
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default MyCell. Value = "total"

Does this look right. For some reason it doesn't work still...


Option Explicit
Dim MyCell, MyRng As Range
Dim i As Integer


Private Sub CommandButton1_Click()
Set MyRng = [a1:a5000]
For Each MyCell In MyRng
If InStr(MyCell.Value, "total") 0 Then
MyCell.Offset(1, 0).Select
Do While i < 4
ActiveCell.EntireRow.Insert
i = i + 1
Loop
ActiveCell.Value = "Avails"
ActiveCell.EntireRow.Interior.ColorIndex = 5
ActiveCell.Offset(1, 0).Value = "Left"
ActiveCell.Offset(1, 0).EntireRow.Interior.ColorIndex = 6
End If
Next MyCell
i = 0
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default MyCell. Value = "total"

Ahh it works. Had to change the casing. "Total"

Now just 1 more thing... to this code and I will post separate.

Thanks for your help!!!!!

Paul

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Custom Data Validation : Lock if MyCell = ""? RayportingMonkey Excel Worksheet Functions 5 October 25th 07 03:14 PM
Linking two "total" pages to create a "Complete Total" page Jordon Excel Worksheet Functions 0 January 10th 06 11:18 PM
Application.Goto reference:="MyCell" akyhne[_2_] Excel Programming 1 August 16th 05 12:30 PM
Search "Total" in all worksheets and delete rows containing "Total" mk_garg20 Excel Programming 2 July 30th 04 06:42 AM


All times are GMT +1. The time now is 10:13 PM.

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"