Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using a variable in formula

Dim MyRow As Integer
Dim Count As Integer
Dim BigCount As Integer

MyRow = 5
Count = 0
BigCount = 0

Do
Do
Range("F" & MyRow & ":F" & MyRow).Select
If ActiveCell.Formula = "" Then
If Count = 0 Then
Range("I" & MyRow & ":I" & MyRow).Cut
Destination:=Range("K" & MyRow & ":K" & MyRow)
Else
Range("K" & MyRow & ":K" & MyRow).Cut
Destination:=Range("I" & MyRow & ":I" & MyRow)
Range("J" & MyRow & ":J" & MyRow).ClearContents
End If
MyRow = MyRow + 1
Else
MyRow = MyRow + 1
End If
Loop Until MyRow = 800
If Count = 0 Then
MyRow = 5
Range("J" & MyRow & ":J" & MyRow).Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-1],RC[-1]:R[740]C[-1])"
Range("J" & MyRow & ":J" & MyRow).Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-1],R5C9:R740C9)"
Range("J" & MyRow & ":J" & MyRow).Select
Selection.AutoFill Destination:=Range("J" & MyRow & ":J" &
740), Type:=xlFillDefault
Range("J" & MyRow & ":J" & 740).Select
Range("I" & MyRow & ":I" & 740).Cut Destination:=Range("L"
& MyRow & ":L" & 740)
Range("L" & MyRow & ":L" & 740).Copy Destination:=Range("I"
& MyRow & ":I" & 740)
Columns("L:L").Select
Selection.EntireColumn.Hidden = True
End If
Count = Count + 1
BigCount = BigCount + 1
MyRow = 5
Loop Until BigCount = 2

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using a variable in formula

Well, that is my code, but here is my text:

I don't think that this is that hard, but I just don't know how to
do it.

Here is my problem. I need to know how to make the "740" in this
rank formula a variable so that when I do a statement that tells me
what the last row with data in it I can assign that row value to the
variable and then use it in the formula.

I am just not sure how to do that.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using a variable in formula

v = "ef"
v1 = "abcd" & v & "ghij"


produces abcdefghih

you would use a similar approach wth formula strings

--
Regards,
Tom Ogilvy'

"DtTall" wrote in message
oups.com...
Dim MyRow As Integer
Dim Count As Integer
Dim BigCount As Integer

MyRow = 5
Count = 0
BigCount = 0

Do
Do
Range("F" & MyRow & ":F" & MyRow).Select
If ActiveCell.Formula = "" Then
If Count = 0 Then
Range("I" & MyRow & ":I" & MyRow).Cut
Destination:=Range("K" & MyRow & ":K" & MyRow)
Else
Range("K" & MyRow & ":K" & MyRow).Cut
Destination:=Range("I" & MyRow & ":I" & MyRow)
Range("J" & MyRow & ":J" & MyRow).ClearContents
End If
MyRow = MyRow + 1
Else
MyRow = MyRow + 1
End If
Loop Until MyRow = 800
If Count = 0 Then
MyRow = 5
Range("J" & MyRow & ":J" & MyRow).Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-1],RC[-1]:R[740]C[-1])"
Range("J" & MyRow & ":J" & MyRow).Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-1],R5C9:R740C9)"
Range("J" & MyRow & ":J" & MyRow).Select
Selection.AutoFill Destination:=Range("J" & MyRow & ":J" &
740), Type:=xlFillDefault
Range("J" & MyRow & ":J" & 740).Select
Range("I" & MyRow & ":I" & 740).Cut Destination:=Range("L"
& MyRow & ":L" & 740)
Range("L" & MyRow & ":L" & 740).Copy Destination:=Range("I"
& MyRow & ":I" & 740)
Columns("L:L").Select
Selection.EntireColumn.Hidden = True
End If
Count = Count + 1
BigCount = BigCount + 1
MyRow = 5
Loop Until BigCount = 2



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
Variable VBA Max Formula Gizmo Excel Discussion (Misc queries) 2 June 6th 08 06:12 AM
Using a variable in a formula [email protected] Excel Discussion (Misc queries) 1 December 29th 06 11:46 AM
Using a second variable within a formula... Ed Anton Excel Discussion (Misc queries) 2 February 18th 05 11:51 AM
use a variable in a formula Marcotte A Excel Programming 2 August 26th 04 01:24 AM
Variable in a formula GM[_2_] Excel Programming 6 March 3rd 04 06:27 PM


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