variable

  1. T

    Object Variable or With block variable not set error

    Hello, Using stream.WhiteLine in a VBA script is giving me the Object variable or With block variable not set error msgbox. Clicking on the Debug button brings me to the line that is written stream.WriteLine " " This is happening at the end of the script. But, I've used the stream.WriteLine...
  2. F

    VBA: Insert formula with variable number of sheets

    Not sure how to get the right syntax here to represent a variable number of sheets. Sub TryThis1() Range("G2").Formula = "=AVERAGE('1:4'!E2)" End Sub The 4 in the formula is the variable part. Whatever number is in Sheets("CtrlPnl").Range("H12") is the total number of sheets. In this...
  3. spencer_time

    Use variable within excel function

    Hello, I have some test code that I can't get to work correctly. I am trying to figure out if it's possible to use a variable within an excel function, and if so, the proper way to do that. The following is what I currently have, it is not working: Sub embedVarFunc() Dim rng As Range...
  4. L

    Excel: Dynamic plot with specific variable on x-axis

    I have a variable Y Y = RANDBETWEEN(2,15) And a variable X X = NOW() I am using the following VBA code to refresh the date; to simulate a real time data flow: Sub Calculate_range() Range("A1:A7").Calculate Application.OnTime DateAdd("s", 2, Now), "Calculate_range"...
  5. MannStewart

    Need macro for OFFSET whcih derives ROWOFFSET from a variable in another cell

    Hi I have a worksheet with a working range of B5:B5000, G2:G5000, H2, V5:V5000. where, V5:V5000 is just =ROW($B5)...downwards, $G$2 contains a function formula that returns a daily overall air-pollution level in decimal value that I make it recalculate each time the worksheet is...
  6. spencer_time

    Active worksheet as variable broken

    Hello guys, I need help again. I have a snippit that works when the sheet is defined (sheet3) but doesn't work when I try to make a variable for the active sheet (ws). I get an error that says "object doesn't support this property or method" and when I press debug it highlights my variable ws...
  7. I

    Using a variable in a formula

    I've seen a similar question to the append with the heading of "Using a variable in a formula", but I can't fine the correct syntax for my particular problem which is as follows: =DATE(YEAR(summary_start_date)+1,MONTH(summary_start_date),DAY(summary_start_date)) I want to change the + part...
  8. M

    Using Colour Codes in an array

    Hi, I have a table that stores the field name in column 1 then the colour code in column 2 (see below) in the VBA code I am trying to use the Colour code. If I use it as a number it works but I can't work out the correct number for the RGB codes I have. How do I pass the array variable...
  9. C

    VBA Formula in Loop Where Main Reference is Variable

    Hey everyone, I'm working on making a macro that will organize data for a mail merge. The main table is contains 62 lines of data for each person, with the first cell containing multiple rows. I'm using substitute to get around this. If we aren't in VBA, the formula would be 'Output'!A3 =...
  10. L

    Error When Defining Variable - Can't Understand Why

    Hi, Why am I getting a run-time error saying, "Object variable or With block variable not set"? The error occurs after the first loop. Here is my code: Dim cell As RangeDim rw As Long For Each cell In Application.Selection cell = cell.Value rw = Range("G:G").Find(cell.Value, ...
  11. D

    Paste formula in empty cells next to a variable range

    Im looking for a vba solution to paste a formula on the empty cells in Column D next to a variable range in column A, any help will be very appreciated.
  12. steveuk87

    Row Height VBA

    HELP!! I need to copy a form over from one sheet to another, i can do this perfectly, only problem is there is alot of formatting etc that i also need taking across. This is all complete except the row heights... Column widths are fine, but the row heights i just cant get right. My problem is...
  13. S

    Excel iPad Auto Calculation with 2 variable Data Tables

    Does the iPad version of excel allow for 2 variable data tables? I have a workbook with 1 and 2 variable data tables that are not updating. Similarly, is there the equivalent of an f9 key for mobile Excel?
  14. tsroque

    Creating a Compound Table for a Variable Term

    Hi! This is NOT an compound interest question. I need to create a compound formula or table to reach a desired answer. EXAMPLE: So if I need to decrease 50 by 20%, 3 times (variable) ------------------------ 1) 50 x .8 = 40 2) 40 x .8 = 32 3) 32 x .8 = 25.6 ------------------------ Answer...
  15. TAPS_MikeDion

    Need to pass one variable to another form, but it's not passing the value.

    Hi everybody, Even after looking over examples found on the forum I still can't seem to get this super simple thing to work. I'm obviously missing something small. I have a main userform that has a "GET CLIENT INFO" button which opens a small userform displaying the client information, but I...
  16. Z

    syntax for range and/or cell declaration

    Trying to Set a range. What is the syntax if I want to use a named cell. "a1" and a variable like lastrow18. I have the variable lastrow18 set as a string and the value is stored as the last row of the column I am evaluating. Ex: Set range18 = Range("a1:lastrow18") What is the proper syntax...
  17. B

    How to avoid clashes between variable names and built-in VBA function names

    By chance, I discovered that Excel doesn't warn you if you declare a variable with the same name as a built-in VBA function. For example, the following compiles without errors: Sub myProcedure Dim Day As String Day = "Monday" End Sub But now, the "Day" function cannot be used. I get...
  18. C

    Value of Cell = COUNTIF with changing criteria taken from list - VBA

    Looking to do a COUNTIF formula but paste it whilst using concatenation to change the criteria each time e.g In column B I have a list of place names and in column C I would like it to show the number of times that place name is present in Column Q. Would need to be setting the value of each...
  19. M

    Macro and formula with variable

    Hi, I wish I could have your help to solve what is a "big problem" for me in VBA. Let me try to explain. I have in column A a series of number, no blank cells. This is a dynamic serie, adding new data every day. In cell C1 I have a variable, a number that I choose. How can I get a formula in...
  20. D

    VBA - What variable types should be manually unloaded at the end of a macro

    Hi, I'm trying to make myself a cleaner coder, and hopefully write code that does not slow down every time I run it. Can anyone help me with a list of variable types that need to be set to nothing or unloaded from memory manually at the end of a macro? Thank you, Daniel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top