Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Find then select to the right

Hello,
I want to search in Column A, example "Total", then move
to Column C so that I can calculate percentage. I did the
following which works fine. But this will only work is if
rows don't change, but this will not be the case. So I
want to be able to find Total then move to the right to
col C to calculate.

Sub Test()
'
r = Cells.Find(What:="Total OEM", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=True).Activate
If r = True Then
Range("C44").Select
ActiveCell.FormulaR1C1 = "=RC[2]/RC[1]"
Range("C44").Select
Selection.NumberFormat = "0.00%"
ElseIf r = False Then
'do nothing
End If
Please advise any help would be very appreciated.
Thanks,
juan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Find then select to the right

Try this:

For i = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(i, "A") = "Total OEM" Then Cells(i, "C") = Cells
(i, "A") / Cells(i, "B")
Next i

John
www.SpreadsheetSolutions.com

-----Original Message-----
Hello,
I want to search in Column A, example "Total", then move
to Column C so that I can calculate percentage. I did the
following which works fine. But this will only work is if
rows don't change, but this will not be the case. So I
want to be able to find Total then move to the right to
col C to calculate.

Sub Test()
'
r = Cells.Find(What:="Total OEM",

After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=True).Activate
If r = True Then
Range("C44").Select
ActiveCell.FormulaR1C1 = "=RC[2]/RC[1]"
Range("C44").Select
Selection.NumberFormat = "0.00%"
ElseIf r = False Then
'do nothing
End If
Please advise any help would be very appreciated.
Thanks,
juan
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Find then select to the right

Hello John,
Your code didn't quite work, but I was able to figure it
out. here's the complete code I use and works:
Dim i as long
For i= 1To ActiveSheet.UsedRange.Rows.Count
If Cells(i,"A") = "Total" Then
Cells(i, "C").Value = Cells (i, "A") / Cells(i, "B")
Elseif 'do nothing
endif
Next i

Thanks for your help. really appreciated it.

Juan

-----Original Message-----
Try this:

For i = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(i, "A") = "Total OEM" Then Cells(i, "C") = Cells
(i, "A") / Cells(i, "B")
Next i

John
www.SpreadsheetSolutions.com

-----Original Message-----
Hello,
I want to search in Column A, example "Total", then move
to Column C so that I can calculate percentage. I did

the
following which works fine. But this will only work is

if
rows don't change, but this will not be the case. So I
want to be able to find Total then move to the right to
col C to calculate.

Sub Test()
'
r = Cells.Find(What:="Total OEM",

After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=True).Activate
If r = True Then
Range("C44").Select
ActiveCell.FormulaR1C1 = "=RC[2]/RC[1]"
Range("C44").Select
Selection.NumberFormat = "0.00%"
ElseIf r = False Then
'do nothing
End If
Please advise any help would be very appreciated.
Thanks,
juan
.

.

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
find&select button, help? Alex Excel Worksheet Functions 0 February 18th 10 11:40 AM
Find & Select Celeste[_2_] Excel Discussion (Misc queries) 3 December 1st 09 05:52 PM
select row if find word CC Excel Discussion (Misc queries) 1 October 15th 09 05:15 PM
find & select Aaron Hodson \(Coversure\) Excel Worksheet Functions 2 August 21st 08 08:36 AM
find and Select cells Richard Excel Discussion (Misc queries) 1 June 23rd 06 12:00 PM


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