variable

  1. M

    VBA Macro: How to reference LastColumn variable in a simple formula

    GOAL: I have a report that will grow by one column of data each day. Each day, I need to add a formula into the first empty column that will find the difference between the value in the last column and another fixed column that will never change. PROBLEM: I have successfully set my variable...
  2. C

    Variable value not passing from function

    Hi, I am a complete VBA beginner so I expect this a very easy question. In the below am trying to check if a file exists. In the below when I check the value of bExists using a Msgbox at the end of the function, the value is true and this is correct. However, if I at the end of the...
  3. B

    VBA - Create Power Query with source and name as variable from Excel sheet

    Hello, I am currently trying to create a Power Query with Excel VBA. I have stored the name and the data source of the Power Query table in an Excel sheet. I now want to start the makro for creating an Power Query table but the makro should read the name and the source of the data from the Excel...
  4. B

    VBA Using range variables for sumifs formula

    HI Guys need some help with this one - Done some searching but couldn't find anything that helps with my particular challenge here The excel function I would to return via vba in Cell L3 is =SUMIFS(G3:G12,H3:H12,"Sales",I3:I12,"<>Excluded")/38 I want to achieve this using VBA and use...
  5. C

    Function with variable reference

    Hi everybody, I am very glad to join you. I have recently started to use vba and so far i am very thrilled about it. I am trying to a enter a function and i am facing the following problem: Dim u As Integer For u = 2 To t - 1 'I calculated the value of variable t earlier in my...
  6. S

    Define a list of files as a variable target (VBA)

    Hello, I use a code to copy files to a template file, and delete old one, then save as old file's name. But choosing every single file for like 500 files, is very boring. Since, I do this operation once a week, now I need more clever way to do it. I use "GetOpenFilename" in order to choose...
  7. K

    Set a variable for workbook name

    So I need to set a workbook name as a variable as it changes every time an updated version is downloaded. So far here is the macro I have set. The problem occurs because the workbook name, which today is "MasterMDs-2020-01-27" will change constantly for the current date. Initially thought of...
  8. K

    Format Month Number Variable as mm ?

    I am writing a script that will save files to a new monthly directory for 3 months in advance. Directory naming convention is this: 04-April 2020 I can get the year and I can get the month name. I can get the month number to return 4, but I need 04. FY = Year(Date) FM =...
  9. E

    Title a Sub Routine with a variable.

    I have over a dozen checkboxes. They are titled checkbox1, checkbox2, checkbox3... etc. They each have a sub routine that tells them what to do when click. These subroutines are identical except for the number that indexes each checkbox. While this was easy to create using copy/paste. It is...
  10. H

    Variable workbook declaration

    Hello I have a workbook that contains data and a VBA to do some tidying up and formatting. I need to be able to open up 2 other workbooks to do a vlookup on, the problem I have is the 2 workbooks change name everyday. How do I declare these other 2 in my main workbook. Any suggestions would be...
  11. T

    For Each Loop

    Following from this thread: https://www.mrexcel.com/forum/excel-questions/1114405-collections.html I was told this piece of information: Syntax ... For Each element In group ... element ... For collections, element can only be a Variant variable, a generic object variable, or any...
  12. V

    Declare a variable to a cell

    Hi everyone! I've been stuck with declaring a variable to a cell value and need some help. Situation: I have a code that filters a table and transfers the filtered data to another sheet. The filter could be the date value but I can't set it properly. The result is always Error 1004. I've tried...
  13. I

    Missing values per case

    Hello! I am new to excel and have learned a lot from these messages boards and hope to keep the learning momentum going. I have a large dataset with over 25k rows and hundreds of columns. I would like to delete rows (participants) who have over 50% missing values per variables. Each column...
  14. G

    How can I set a range variable that only includes cells in that range with data?

    I have a very slow subroutine that uses a For Each statement to iterate through about 30 cells in a pre-defined range, checking if they have text in them, and then performing a bunch of formatting based on the text in that cell. I'm wondering if there is a faster way to do this that would...
  15. B

    Looking up data in other worbooks

    I have a table where I have to draw data from a number of workbooks While the table is across multiple columns, it is between rows 2 and 201 So in cell AB2 I have this formula =VLOOKUP($A3,[Trap12.xlsm]Squadding!$K$3:$P$202,2,FALSE) This is the formula I tried to pick up the variable which is...
  16. K

    VBA: save document to path from variable

    Hello all, In have a file path saved as the variable "File_Path". Now I want to save a workbook to that path. I'm using the following code: WB2.SaveAs Filename:= _ File_Path _ , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False It is not recognising "File_Path" as...
  17. R

    Declaring variable types within an array

    I have an array with a mix of data types (strings, dates, integers, etc...). When I use the watch window for debugging, some date values show up as dates, but others as a real number (which isn't very helpful). Not sure how that happens, but that question is for another time. In the...
  18. glfiedler

    VBA intellisense data

    I dimensioned a variable as Dim rowS without thinking. I have been coding for decades so I know using "rowS" as a variable is, of course, a bad idea even thought the vba editor is smart enough to take context into account and keeps running smoothly. As soon as I realized my mistake I deleted...
  19. Johnny Thunder

    Formula Help - SumProduct with multiple Conditions that include a wildcard

    Hello All, I am hoping this is an easy one, I have a sumproduct formula that looks at multiple conditions and it works great but the business just threw in a new variable and I was hoping it will be a quick modification to the formula to get it to work. Here is the formula...
  20. C

    VBA To find match of cell value and copy adjacent cell when match found

    Looking for vba code to see if data from 2 different cells on 2 different sheets if it matches then it copies the cell to the right on sheet 2 and pastes it to the cell on the right on sheet 1. All the data in sheet 1 column M is present on sheet 2 column A. So when it finds a match in column M...

Some videos you may like

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top