Find Max Value In A Changing (variable Range)

May 11, 2009

I am trying to find the max value within a range (14 cells) contained in one column ("C" in this case). This range will change corresponding to the current cell. Ex. as the current cell moves down (or increases in number) the range of cells to find the Max in moves down (or increases in number) as well. The Max value will then be used as a variable in a equation but for now just getting it into a cell is fine. This seems like it would be easy but it is driving me absolutely batty!

I currently have the non-working code located in a For loop that contains other calculations as well. I've taken those calculations out since they work fine but cloud the bad part. So far I have tried:

View 3 Replies


Changing Range Selected With Variable

Jan 17, 2009

I have some code that uses offset to select a column of numbers

View 2 Replies View Related

Chart/Graph Changing/Variable Range

May 28, 2008

I have a vast database where I have linked charts. I send the data from a macro to the database and sometimes there are 1000 inputs and sometimes there are only 20.
How would i set up my charts to only graph the inputs that are present?

View 7 Replies View Related

Find A Variable Through A Source Range

Apr 19, 2006

Im using these two codes to find a variable thru a source range. Everything looks to be working well, but as soon the macro tries to copy the returned range I got the following message. Run-time error 1004: Copy method of Range class failed

However, when I press the end button in the error window, the returned range is copied into the target range. Does anybody know how to avoid the error message? Also, is there any way to pass the returned range to an array?

The source range is 40,000 rows by 14 columns
The returned range is 163 rows by 14 columns.

Sub SearchRangeOne()
Dim SourceRange As Range
Dim TargetRange As Range
Application. ScreenUpdating = False
Set SourceRange = Worksheets("Actual").Range("Actual_Key")

If Not Find_Range(Range("A1").Value, SourceRange, xlValues, xlPart) Is Nothing Then.............

View 8 Replies View Related

Find And Find Again - Object Variable Or With Block Variable Not Set

Jun 5, 2007

After doing a search, I need to ask an Excel 2003 question. I'm creating a tool to open three sparate workbooks. One is the driver and I need to use it to pull data from the second and then to place that data along with additional data into the third.

My driver data may consist of a single value or multiple values separated by semi-colons in a cell. A single value works fine. The first value in a multi-value condition works fine. the second find, however, gives me an object error. I'm using the " split" verb to separate the values. Here's my code. Have you any idea why the second find is throwing up this error when the first find works correctly?

varData = Split(strRef, ";", -1)
For J = 0 To UBound(varData)

varSrchVlu = Trim(varData(J))
' do the ARIS Exrtact matching
Workbooks(strARISExtract).Activate ' Activate ARIS Extract
Sheets("Processes").Cells(2, 1).Activate

View 3 Replies View Related

Find Last Cell In Range, And Changing Another Cell Based On Offset Text

May 4, 2009

If i have a range say E12:O12 and want to find the last cell before blank, lets say it finds m12 as the cell with the value before blank. then with m12 it needs to determine weather row 11 in the same column has Text either "S" or "F" if "S" then m12 = t if "F" then m12 offset(1,-1) = t. And just to make things more difficult i need the range E12:O12 to step 2 as well until it gets to E208:O208 .Noting that row 11 never changes and will always have either an "S" Or an "F"

and also t = time()

View 7 Replies View Related

Find Method Code: Object Variable Or With Block Variable Not Set

Sep 8, 2006

I need my program to:
- find the cell containing the string "Datum/Tid"
- record the column and the row of the found cell in two variables lCol and lRow

Here is my

Sub test()

Dim rFoundCell As Range
Dim lRow As Long
Dim lCol As Long

'Find method of VBA
Set rFoundCell = Range("A1")
Set rFoundCell = Worksheets("Sheet1").Range("A1:Z50").Find(What:="Datum/Tid", After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

'for anyof the two lines down I get the message "object variable OR block variable not set"

lRow = rFoundCell.Row
lCol = rFoundCell.Column

End Sub

View 5 Replies View Related

Find Dates Macro: Object Variable With Block Variable Not Set

Nov 21, 2006

I found this nice little bit of code for a date range search in column A but it will not work. Apparently i have not set a variable or something.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim startDate As String
Dim stopDate As String
Dim startRow As Integer
Dim stopRow As Integer
startDate = InputBox("Enter the Start Date: (dd/mm/yyyy)")
If startDate = "" Then End
stopDate = InputBox("Enter the Stop Date: (dd/mm/yyyy)")
If stopDate = "" Then End
startDate = Format(startDate, "dd/mm/yyyy")
stopDate = Format(stopDate, "dd/mm/yyyy")
startRow = Worksheets("sheet1").Columns("A").Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
stopRow = Worksheets("sheet1").Columns("A").Find(stopDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
Worksheets("Sheet1").Range("A" & startRow & ":A" & stopRow).Select

End Sub

View 9 Replies View Related

Find Method: Object Variable Or With Block Variable Not Set

Aug 28, 2006

I have a spreadsheet form with all kind of values and what I want to do is to find a data in a worksheet named "Config" based on the spreadsheet activecell value. With the find row adress I return data of another column but same row (in the worksheet) in two diferent label captions. If the spreadsheet activecell value it was found in the worksheet everything is ok but if the value is not found I'm getting the message "Object variable or with block variable not set"....

View 7 Replies View Related

Changing Variable According To For - Next

Apr 18, 2007

Sub Macro1()
Dim blue1 As String, blue2 As String, blue3 As String, num As Integer
blue1 = "one"
blue2 = "two"
blue3 = "three"
For num = 1 To 3
ActiveCell.Value = blue & num
ActiveCell. Offset(0, 1).Select
Next num
End Sub

What I am trying to achieve is to use the appropriate "blue#" variable according to the num variable. For example, when num = 1, I want the macro to use the variable blue1. I am not sure how I should code this.

View 2 Replies View Related

Stripping Out And Changing Time From Variable With VBA

Jan 31, 2014

I have a macro that needs to work with data including different time from different sources.some of the cells are date and some are text.

I have the following function

Public Function TidyDate(zdate) ' This is coming in as a date #01/02/03 08:00:00#
Dim TempVar1, Tempvar2 As String
TempVar1 = zdate
Tempvar2 = Left(TempVar1, 11) & "00:00:01"
TempVar1 = Tempvar2

[Code] ....

What i need is to change the time of the variable to 1minute past midnight but keep the date the same.

View 5 Replies View Related

Changing Font Of A String Variable?

Nov 28, 2012

I'm taking some university classes and one of them is called Applications Programming and we have been using excel VBA. I have a project that I'm working on, and it's very basic. Basically we need to create a userform that has 3 option buttons, 4 check boxes, a couple labels and a couple text boxes. It's suppose to be a ice cream selection terminal. Option boxes for basic flavors of ice cream, check boxes for toppings, one text box for user input of number of scoops of ice cream and the last text box to output a reciept/overview of purchase.

So here's the question... I was wondering if there's a way to change the font of a single string variable, or change the font of a word within a string. My output to the saleBox(My receipt overview) is this:

saleBox.Text = ("Thanks you for your Purchase") & vbCrLf & vbCrLf & _
"You ordered " & numOfScoop & " scoops of " & flavorChoice & "ice cream" & vbCrLf & _ "Topped with: " & toppings & vbCrLf & vbCrLf & total

(not sure how the code is gonna look in the message but I'm sure you get the idea)

i want to be able to change the font for the flavorChoice or toppings variables. They are both strings.

Anyways, I know I can get away with basically what I have there and get full marks, but I like going above what the basics are. If it's kinda complicated.

I'm gonna attach a screenshot, more info is better than not enough right... nevermind its askin for a url!

*** I just now got the idea of putting another textbox over the area that would output the text I want to change and hide the border or something and then change the font of that text box through the properties ***

View 3 Replies View Related

VBA: How To Program A Changing Variable Name In A Loop

May 20, 2006

Trying to code my first custom VBA function. The function is supposed to translate the words in a cell by repeatedly looping through the string and looking through a list of provided translation words.

Problem is the variable name changes with each loop, and I can't figure out how to program the name change.

Function TestTranslate(TranslateCell, ProductCell) As String

Dim t As Long
Dim TranslateCeiling As Long
Dim SS1 As String
Dim SS As String
Dim Q, R As String
Dim W As String
Dim LLRString, MLRString, SLRString As String
Dim LRString, MRString, SRString As String
Dim TArray() As String

Looks like the loop keeps defining Q as "SS" & t instead of doing the select case formula. I tried removing the Q variable altogether and making it read just "SS" & t = Replace(R, LLRString, LRString) for example and keep getting a compile error.

View 9 Replies View Related

Changing Font Color For String Variable?

Apr 18, 2012

how to or if it's possible to change the font color of a string variable? or is there any workaround?

View 2 Replies View Related

Changing Vlookup Ref Column Based On Vb Variable

Jun 20, 2007

I am pasting vlookup formulas into a spreadsheet using a macro, and want to change the reference column number based on a variable generated within the code eg

= vlookup(RC1,table,i,false) where i is a predetermined variable in the code

for i=23, I need the result to be of the form


View 7 Replies View Related

Lookup Based On Variable/Changing Sheet Name

May 23, 2008

I'm trying to figure out a way to lookup a value based on a conditional sheet name. I'm finding it difficult to explain in words what I'm trying to do, so I'm going to try and describe it in a miniature example of my spreadsheet. I apologize if this is going against forum rules, this seems like the quickest way to get my question across:

The following is the way my spreadsheet's first page is set up:

ID Apr-08 Mar-08 Feb-08

The column labels depend on another table, which changes monthly.
The rest of the sheets (24 of them, labled "200804", "200803", etc) look like this:

ID $ amount Date paid

I have another table upon which the na

I'm trying to return the "Date Paid" value for each ID for each month. Each month, however, more data arrives, and the labels change. I have several dozen spreadsheets formatted in this way, and I'm trying to avoid having to change the vlookup (or other formula) manually each month for each sheet. Is there a way to make the vlookup depend on a table?

This is essentially what my formula looks like right now for cell A2:
=VLOOKUP($A2,'200804'!$A$1:$G$10000, 3, FALSE)

If I could replace '200804' with a cell reference, that would be ideal. I haven't been able to figure out how (if possible); I tried experimenting with index sheets but that went nowhere.

View 9 Replies View Related

Variable Type Changing Number Of Decimal Places

May 14, 2014

Here's what I'm doing: I'm using a macro to assign a cell value to a variable then set another cell value to the variable instead of copy/paste (because even pasting values only was affecting other formulas in the file for some reason)

The problem: in using the macro, the number being 'copied' is acquiring a few extra decimal places IE 38334.61 is the original number and 38334.609375 is what I end up with. The numbers come from a CSV with only 2 decimal places and I checked by adding decimal places in the format so it's not a formatting/visible digits issue. Since the values are hour meter readings, the extra decimal places end up with very small values outside 0-24 hrs which messes with sorting and usage %. The values are so small all of them together in a month add up to a fraction of a cent but it's one of those things that bugs my OCD by not being right.

My VBA book explains the min/max capabilities, content type, memory bits but not fiddly details like this.

So my question is this: right now I'm declaring the clipboard-substitue variable as an single, is there a different one that would work better without adding anything? Criteria are: numeric, 6 digits before the decimal, 2 after, all positive values. (Ie 123456.12)

EDIT: fixed my senior moment.

View 6 Replies View Related

String Variable To Call Defined Range Variable

Nov 10, 2006

Say you define a public range variable called Inputworksheet and you set it to refer to the worksheet called Inputworksheet. You have a separate string variable with the value Inputworksheet. How do you get this string variable value to call/control the range variable Inputworksheet?

I am getting an excel worksheet value from a lookup function that corresponds to the name of a VBA range variable. Once I have this worksheet value, I would like to use the range variable that has the same name as the worksheet value.

View 5 Replies View Related

Autofill With Range That Is Column Variable And Row Variable

Apr 4, 2008

I am trying to autofill dynamic ranges that have column variables (d) and row variables (x)... I am having a hard time with the syntax on this

View 9 Replies View Related

Select A Range That Will Be Changing By Column: Method 'Range' Of Object '_worksheet' Failed

Jan 6, 2010

I'm trying to select a range that will be changing by column. I'm not sure why my syntax isn't working. What I've got:

View 2 Replies View Related

Stop Graph From Changing Named Range To Formula Range

Sep 8, 2006

I am trying to create a graph for a range of data that updates monthly (adding an extra month each time). I wanted the graph source data to update automatically each time the data is refreshed so used an OFFSET formula to identify a named range. I then point the graph to the named range as the source data.

When I enter the range as the source data the graph picks it up. However, when I re-enter the source data option on the graph it has converted the named range into a cell written range (ie. replaces "=QUALITY" with "='Front page'!$B$7:$J$10" - which therefore will not update when the range increases.

View 4 Replies View Related

Set Range Variable Using Variable Row Number

Mar 11, 2008

I am using a variable named " Totals" as a range type to refference the range in a formula. It works the way I have it.

Dim Totals As Range
Set Totals = [U37: AE37]

Now instead of the absolute refference, I would like to change the row refference by an offset of my current row, using a formula with a varriable. The columns stay the same.

View 3 Replies View Related

Changing The Background Of A Range Based On Text In The Range

Oct 20, 2008

I have been tasked with creating a scheduling system for my work. There are three groups of shifts that can be selected, Opens, Swings, and Closes. I have been asked to make the cells turn red if a user selects a sequence of shifts. We are trying to avoid having a person working three scenarios:


If they select the shift that meet this scenario, then I need the cells to turn red. The complete list of shifts are on the "Data" tab and the the three scenarios have been inputted into the "Jan" tab in E13:G15.

I am using the code below to change the background of the cells in my worksheet based on what is in the cell. How can I modify it to accomplish the changes below and meet the criteria above?

View 12 Replies View Related

Find Max Value Of Dynamically Changing List

Jun 20, 2008

my file was too big to attach, so to get it, go to [url] (p: SOCIALCHARM [all caps]). It's the only file underneath the 'documents' section.

This is a complex sheet, so I won't go into everything I'm doing, but really just the part I need help with. Instead of trying to explain it abstractly, I'll use a a concrete example (you'll need to look at the sheet to understand this).

The general idea is that I results from an online ad campaign (ie I ran ad X on site Y in position Z), and - given the results I have - try to optimize which ads I run where. Each in the real data (row 167 and below) represents a 'space' where an add can be run.

First, row 551:
The original recommendation is in Column T, which is Brand "Buddies" (column V). The total # so far for brand "Buddies" (col W) is less than the limit, so Column X = 0, and the updated recommendation (Column Y) is just the original recommendation from Column T.

Now, row 552, (the condition I'm having trouble with)
The original recommendation is in Column T, which is Brand "Pink" (column V). The total # so far for brand "Pink" (col W), however, is now OVER the limit, so Column X = 1. This means that excel now needs to search all of the creatives (in column E), filter out all the ones that don't match the size of the current creative in question (ie that are not of size 300x250 - E551), ALSO filter out any creatives of brands that have already hit their limit (in this example, brand "2-in-1" has already hit it's limit, as you could check by looking at X537), THEN, from the remaining creatives (ie those of size 300x250 and not of brand pink OR of brand 2-in-1), select the creative with the highest value in Column AI).

View 3 Replies View Related

How Do You Stop Changing The Date Format During Find And Replace?

Aug 26, 2009

When I remove "Release date:" from "Release date:24 December 2008," excel will automatically change the text to "24-Dec-08." Yes, I did try to format the column to "text" before using find and replace.

This wouldn't be a problem, except that half the dates are in Dutch, so only half the dates are changed, which means that I can't make all date formats in a column uniform.

View 2 Replies View Related

Autofill In Macro Range Is Constant How Can I Code To Be A Variable Range?

Feb 19, 2010

I am trying to write a macro which will autofill specific columns. The macro will set the range from the start of my autofill to the end of my autofill as a constant range.

The problem I need to get around is the end of my range can always change each time I run the macro. For instance, the first time I run the macro I may only need to autofill from row 4 to row 15. The next time, I may only need to autofill from row 4 to 23 (because of user updates). How can I make the end of my range not be a constant address but variable?

View 6 Replies View Related

VBA Solver: Find Minimum Value Of Cell By Changing X Cells With Constraints

Mar 18, 2009

I'm trying to use solver to find the minimum value of a cell by changing 5 separate cells. These cells are subject to a set of constraints that are formulae. On top of that I have a large number of these solve's to run (The spreadsheet is creating randomly distributed data to form a Monte Carlo simulation). Therefore I am referencing the formulas using the ActiveCell, Offset() function. For some reason when running this code none of the values are changed. Also I changed the UserFinish to false so I could see what solver was doing at each solve, It stops at the correct cell (one after the final cell) but without me having to confirm it each time.

Here is the ....

View 3 Replies View Related

Changing Hard Coded Column References To Variable References

Oct 22, 2009

I have a number of statements within the Sheet Event Code (Excel 2007). Three times lately I have added a column and had to go back into the code and find all of the references that needed changing to reflect the new column.

I have been working on this for a couple of days and even tried EE, but to no success.

I have read that Defined Names / Constants should be used as often as possible, but even trying that, the VBA code errors out or "hangs up". Even within Bill Jalen's book (VBA and Macros 2007), there is nothing that addresses this, especially using Intersect.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

On Error GoTo mEnd
Set rng = Sheets("Log").[F14:F10000]
If Not Intersect(rng, Target) Is Nothing Then
If Target = "" Then
With Sheets("Log")

View 9 Replies View Related

Find Variable's First Row And Last Row

Feb 22, 2014

Column A:


I would like to find the row that the first and last C is at.

first and last row should be 6 and 8 respectively.

View 5 Replies View Related

Using Find With A Variable

Mar 16, 2014

I'm trying to write code, that uses a variable when using the find function. When I put the variable in the "WHAT" it's not reading the value.

Here's my code:

For f = 1 To g
H = ActiveCell.Value
Sheets("IPO TEMPLATE").Activate
Set FindQueryUPC = Selection.Find(What:="H", After:=ActiveCell, LookIn:=xlValues, _

[Code] ..........

View 3 Replies View Related

Copyrights 2005-15, All rights reserved