variable

  1. 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...
  2. 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...
  3. 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...
  4. 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...
  5. 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...
  6. 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 =...
  7. 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...
  8. 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...
  9. 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...
  10. 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...
  11. 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...
  12. gravanoc

    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...
  13. 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...
  14. 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...
  15. 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...
  16. 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...
  17. 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...
  18. 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...
  19. S

    Adding worksheet to a range variable

    Hi I tried to add the worksheet information to a range variable which was passed from a main routine. "Received_range" is the range variable received and all of the three lines below has resulted in error. a. Set localrange = Sheets("Sheet1").received_range b. Set localrange =...
  20. C

    Problem with VBA Loop

    Hi, I want to loop through rows in my worksheet and compare the cell values in particular columns with other rows defining a variable as True or False (my segment_trigger variable below) if the values are the same or different. I have written the following code but its giving me "Compile...

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