Variables And Constants Query

Oct 13, 2006

how do you assign a value to the variable to make it available to the module?

I have tried the following without success


Option Explicit
Dim batch As String
Dim folder As String
Dim title As String

batch = Sheets("Day 1"). Range("D1")
folder = "M:CR dim checksRetention"
title = folder & batch
file = title & ".xls"

View 9 Replies


ADVERTISEMENT

Constants Are ($) Variables Are?

Apr 14, 2007

While $ are constants for cells what is the symbol for variables? I guess when I dragged a formula down rows a certain number did not increase so I had to manually up each one as I went down the rows.

View 4 Replies View Related

Auto Creation Of Variables / Constants

Mar 25, 2007

I am trying to create a set of global variables (or actually constants) that can be used in my program based on two columns found in a spreadsheet. The first column in the spreadsheet contains the name of the variable, and the second column contains its value.

VarName VarValue
Var1 abc
var2 def
var3 ghi

When the program (which is an Add-in) is called by the user, the very first thing that I would like the program to do is to create each variable from the first column and assign the string value from the second column to this variable (or constant).

View 9 Replies View Related

Reference Variables / Constants In Add-in From Workbook

Feb 21, 2008

I'm wondering if it is possible to declare a constant in an add in, and then reference that constant from workbooks that use that add in?

Basically I want to set a version number in the add in, and check it from the workbook.

View 3 Replies View Related

Concatenate Query; Include 2 Variables With 1 Constant Entry

Jan 23, 2009

I have recently discovered the concatenate formula. Is it possible to include 2 variables with 1 constant entry. i.e. I wish to establish file names with 2 variables, e.g. 0051 and 1025 followed by a file extension, .EC0 - the file name being 00511025.EC0. The variables are in Excel columns. I can achieve the wanted result by establishing an extra column and copying .EC0 into every cell of that column; but I would prefer not to have that extra column in the completed Excel file.

View 2 Replies View Related

Query Tables DataTypes And ColumnWidths Arrays As Variables

Jul 12, 2011

How do I set the datatypes and columnwidths as variables? I get invalid procedure call or argument. Will import different text files and set dt and cw based on names.

Dim dt As Variant
Dim cw As Variant
dt = "2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2"
cw = "7, 7, 5, 2, 7, 16, 3, 15, 11, 9, 9, 9, 7, 3, 3"
With ActiveSheet.QueryTables.Add(Connection:="TEXT;B:BOMOEBTRfro1.txt", Destination:=Range("A1"))

[Code] ........

View 8 Replies View Related

Constants As Arrays In Vba?

Apr 16, 2009

Can you declare a const as an array in VBA? For example, let's say I wanted to define an array of ORDINALS:

Const ORDINALS(0 to 9) = ("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th")

View 2 Replies View Related

Select Constants

Aug 3, 2007

Can a macro be provided for selecting cells (including hidden) in the active sheet which are :

1. Totally consants ie not used in formula either in same sheet or other sheets

2. Constants ie figures used in formula in the same sheet and/or other sheets

View 9 Replies View Related

Using Constants In Same Module

Oct 15, 2009

I declared a constant like so:

Public Const iFirstRow As Integer = 6

I figured that any time I used this, at least in the same module, its value would be 6, but it was 0.

I changed it to ModuleName.iFirstRow, which seemed to set it straight.

Is this just how it is, or am I doing something wrong that is preventing me from using it without the module name?

View 9 Replies View Related

Sum Formula With Constants

Jun 23, 2007

I have a Excel budget spreadsheet. I need a running formula I can copy and paste to other month cells.

SUM=Bal+interest+interest1-pmt

=SUM(B11+B4+C11-D11) Interest(B4), interest1(C11) and pmt(D11) are constants. The formula I am using works but it won't copy and paste.

View 3 Replies View Related

Detecting Formulas Vs. Constants

Oct 1, 2006

In my company we have many spreadsheets with sections that contain formulas, which may be overwritten with "hard coding", manually entered constants, in certain situations.

Is there a way I can detect the differences between the two types of cells? I would like to setup conditional formatting that would highlight constants in a table that would generally only contains formulas.

View 14 Replies View Related

Compare Value Of X Cells To Constants

Apr 3, 2008

I need the SUM function. I know how to use SUM and in one of my workbooks it is used quite a few times, but for two columns it will not add the columns up. In the Q column I have this formula throughout the cells: {=IF(AND($H6="DM",$J6=1),"$100.00","")} and the other column is just about the same (just has different H6 value). Then I have a cell with the formula {=SUM(Q6:Q900)} and the end result is $ -. This formula is used for other columns and it works just fine. I have checked the formatting in all the cells and have changed them to General, Number, Currency, and Accounting. None of those working. I have also checked the Calculation Tab in Tools>Options... and it is set to automatic.

View 4 Replies View Related

Named Range / Constants In Formulas?

Apr 11, 2014

I have the following formula.

=SUMIFS('Register Sales'!$E$51:$C$2500,'Register Sales'!$C$51:,A2,'Register Sales'!$L$51:$L$2500,D2)

The range changes each month so I want to use a named cell "LastRow" where I can change the number to replace the 2500. How do I use the range name in my formula without giving me a #value# error?

View 1 Replies View Related

Flag Cells With Constants In Formulas

Feb 6, 2008

I'm dealing with a lot of spreadsheets put together by people who are not that familiar with Excel. Because of this, there are many instances where the formulas created include constants. For example: = A1 * B1 + 200. I want to create a VBA routine that will cycle through the cells I selected and "flag" those cells that have a constant in the formula.

View 3 Replies View Related

Using Array Constants In User-defined In Vba Function

Oct 1, 2009

I have a function in VBA of the type. Function MyFunc(Indx As Integer, k As Long, Rho As Range, A As Range) As Variant .... End Function

which is called as a user-defined function from within the Excel worksheet. When called with the last two arguments being a range (i.e. Result = MyFunc(1,98,A1:A2, B1:B2)) it works fine. However, when I try to directly use an array constant instead of a range (i.e. Result = MyFunc(1,98,{10,11}, {20,30}), it returns a #VALUE error.

I thought I could fix it by redefining the last two arguments as arrays of type double, but this didn't work either (i.e. Function MyFunc(Indx As Integer, k As Long, Rho() As Double, A() As Double) As Variant .... End Function ).

View 3 Replies View Related

Change Numeric Constants In Column To Zeros

Oct 13, 2009

I have the following code

Call LastCell_Example(LastCell)
lastrow = Cells(Rows.Count, "B").End(xlUp).row
Set Datarange = ActiveSheet.Range("B1:" & LastCell)
' Set to 0 all cells that contain constants, but ONLY those that are numeric
Datarange.SpecialCells(xlCellTypeConstants, xlNumbers) = 0

lastcell_example contains

Dim rng As Range

' Use all cells on the sheet
Set rng = Sheets("Courtage").Cells

' Find the last cell
LastCell = Last(3, rng)

' Select from A1 till the last cell in Rng
With rng.Parent
.Select
.Range("A1", LastCell).Select
End With

When I run the code above, I don't understand the fact that the first rows in the sheet AFTER "Courtage" are also being changed to zero.

Obviously, I'm not limiting my datarange correctly, but could someone explain what I need to do to limit the changed data to ONLY the current sheet.

View 7 Replies View Related

Array Constant Composed Of Named Constants

Jun 20, 2008

I try to understand what the syntax is to create and use an array named constant which would be composed of other constant.

Example :
Constant called AvgZone1 which is =AVERAGE(zone1)
Constant called AvgZone2 which is =AVERAGE(zone2)

and then create a named array constant based on the names : =AvgZone1,AvgZone2
is not working. You cannot for example do a SUM().

View 9 Replies View Related

Cell Type Constants Returns Wrong Order

Nov 28, 2007

I'd like to add items on a UserForm1 ComboBoxes in the correct order but I can't. That's because with the code below, in ComboBox6P1 the items are added with mixed order:

For Each thing In .Range("AC6", .Range("AC65536").End(xlUp)).SpecialCells(xlCellTypeConstants)
If Trim(ComboBox4P1.Text) = thing.Value Then
For Each aNew In .Range("AD6", .Range("AD65536").End(xlToRight)).SpecialCells(xlCellTypeConstants)
If aNew.Row = thing.Row Then
ComboBox6P1.AddItem aNew.Value
End If
Next
Exit For
End If
Next

I should add items in ComboBox6P1 in order -> AD6, AE6, AF6, AG6, AH6, the rest are empty cells. Instead of it adds AF6, AG6, AH6, AD6, AE6. When I change .SpecialCells(xlCellTypeConstants) to .SpecialCells(xlCellTypeVisible ) it adds it in the correct order but with another 200 emtpy cells in the ComboBox6P1. The format of the cells is General.

View 9 Replies View Related

Pass Parameter From Excel Through MS Query To MS Access Query

Nov 26, 2012

I have an MS Access query that contains a parameter. The parameter is a date field, and I have configured that in the Access query. If I run the query within the MS Access user interface, it prompts me for the paramater value as expected, and runs just fine. However, I want to connect to this query from within Excel as a data source.

I have created a connection to the Access file using ODBC from within Excel. In the MS Query window, I am merely selecting all of the fields resident in the MS Access query, and returning all values. In other words, there is no selection criteria in the MS Query. I have done this many times with Access queries that DO NOT contain a parameter, and everything works fine. However, in this instance, I need to pass a parameter through to MS Access in order for the query to run. At the moment, I get the "Too Few Paramaters...1 expected" error message. This makes sense, because I haven't figured out how to pass the paramater to MS Access.

Is there a way to structure this that does not involve VB code? If so, I'd love to know how. I have tried creating parameters in MS-Query with the same name, but although I get the prompt it doesn't connect with the Access query as the source for the parameter value.

If the solution requires using code, I'm good with VB Code in Excel...is there VB for Excel code that could make this happen?

Failing that, I guess there must be (I've seen a few in my search thus far) Access VB Code that can make this work. I'm very rusty using VB with Access, so this is my least favored solution. However, if this is the only option, keep in mind that I need to pass the paramater ultimately from a user who will initiate the process using Excel.

View 3 Replies View Related

Query Parameters Which Takes The Date From The Cell Into The Query

Mar 29, 2007

Need the query parameters which takes the date from the cell into the query. How should I modify my query if it needs to take the date from a cell?? The bold one date should be picked from one of the cell in sheet 2.

My query is this
WEB
1
http://fc-web-phl1-101.phl1:8090/gp/...runReport.y=12

Selection=15
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False

View 2 Replies View Related

Conditional Formatting To Highlight Cells With Formulas (versus Constants)

Nov 24, 2010

Is it possible to use conditional formatting to highlight cells that use formulas, as opposed to having constants?

I have a sheet that uses formulas to provide a default value, but you can type in a number if you want to replace the default. I want to be able to easily identify which ones use the default formula.

If I use functions like FIND, they look at the result of a formula, and not the formula itself.

I know I can write a UDF that will figure it out but I was wondering if there is some built-in way.

View 7 Replies View Related

Data Validation Fails With Named Range Of Array Of Constants?

Oct 27, 2013

I've set up a Named Range that refers to an array of constants, e.g. MyRange ={1,2,3,4,5}. This appears to be fine since I can output the named range to a range of cells in a row (e.g. A1:E1) and see 1,2,3,4,5 (one value in each column).

I'd like to use MyRange as the source for a Data Validation list in a cell.

Normally data validation list sources must be vertical, so I've set MyRange =TRANSPOSE({1,2,3,4,5}). This appears to be fine since I can output the named range to a range of cells in a column (e.g. A1:A5) and see 1,2,3,4,5 (one value in each row).

When I set MyRange as the source for data validation however, it resolves to an error.

why this setup doesn't work?

Workbook detailing the problem attached. Attachment 273788 NamedRangeDataValidationArrayConstansts.xlsx

View 3 Replies View Related

Class Modules: Provide Users With In-Code List Of Constants

Jul 8, 2009

I am working with a class module and some fields require specific inputs that another coder may not intuitively know. How can I create a list of acceptable conastants that will appear as a drop down when the user is coding with the custom object?

For example:
I am creating an Email Engine object that will handle all my emailing needs in code, because coding emails is such a pain. Then I can just create the blasted thing, import the class module where needed and never have to worry about it again. Some coworkers are interested in using the module for their projects when I am finished. I want to put an option for message flags in the object, but only certain colored flags are allowed. How can I get the VBE to show a little drop down with the acceptable flag constants when another user types

[Object Variable].MessageFlagColor = {drop down list of options}
I started with

Public Property Let MessageFlagColor(Value As Constants)

End Property
But that hasn't gotten me anywhere.

View 9 Replies View Related

Format Formulas, Constants, Numbers & Text Cells Differently

May 8, 2008

I am attempting to write a VBA function that will add textual formatting to each cell that has content. I am just learning VBA; so far, as an example I have

Sub NewSub()
i = 1
j = 1
Do
Cells(i, j) = "'" & Range(i.j).Value & "',"
i = i + 1
Loop Until i = 40
End Sub

but, as I'm sure you'll notice, it does not work. In essence I want to wrap quotes and follow with a comma each cell that contains any content. The actual content test I haven't gotten to yet.

View 6 Replies View Related

Unzip Code - Works Without Variables, Breaks With Variables...

Feb 5, 2009

Unzip Code - Works without Variables, Breaks with Variables.... This has been driving me bananas...

I have the

View 2 Replies View Related

Create An Conection With MS QUERY To A Csv And Query Data

Sep 6, 2008

I have a csv file on another drive on the network that i need to query. I believe that ms query would be the best way. I know that a DSN needs to be setup but this macro will be used by various users who wont know how to do that. thus I would like to create one via VBA every time the task needs to be run.
I haven't a clue how to do this and i need it to be explained to me in general terms with words of one syllable!

View 9 Replies View Related

Query An Access Query With VBA Function

Jul 8, 2008

I'm trying to query a query in Access 2003, from Excel 2003.

The query in Access looks like:
AccessQuery: [SELECT VBAFunction(field1) FROM Table]

The query in Excel looks like:
ExcelQuery: [SELECT * FROM AccessQuery]

I use the following VBA code in Excel to excecute the query:

With ThisWorkbook.Worksheets(cDataSheetName).QueryTables.Add(Connection:=strConnection, _
Destination:=ThisWorkbook.Worksheets(cDataSheetName).Range("A1"), Sql:=strQuery)
.RowNumbers = True
.Refresh BackgroundQuery:=False
iResultRowCount = .ResultRange.Rows.Count
End With
When I execute this code I get the error message 'SQL Syntax Error' (Error 1004). When I remove the VBA function from the query in Access, it all works fine.

View 9 Replies View Related

Edit Query Using Query Wizard

Apr 25, 2006

I created an Ms Excel Database Query to bring in data from MS Access. (versions 2002 of MS Excel and Ms Access). The query works fine initially. I can right click, choose Edit Query and change my criteria. Results are returned almost instantly.

My problem is that, once I save the workbook, or autosave happens, I get an error when I right-click to Edit Query: This query cannot be edited by the Query Wizard..

View 2 Replies View Related

VBA To Read Text Formula And Related Constants And Insert As Formula Into Cell

Jul 30, 2014

I have a situation where I have to curve fit data, this can lead to different formulas being used with varying constants.

Is it possible to pickup a TEXT based formula and related constants from other cells, and then place this into another cell as a functioning formula. For Example

Cell A1 contains the formula as a text string whether it be y=a+bx+cx^2, or y=a+b/x, etc
Cells A2:A6 contain the individual constants, a, b, c, etc

I would then want the VBA to read the text based formula and put it into an output cell as a functioning excel formulae.g

In cell B10: =a+b*A10+c*A10^2

I understand picking the constants up and putting the formula should not be too much of an issue, however trying to insert the variable form of the curve fit is the part that I am struggling with, and am unsure if possible.

View 2 Replies View Related

MS Query - Parameters (parameters On A Query But Use A Wildcard To Return All Instances)

Nov 17, 2009

Is it possible to set parameters on a query but use a wildcard to return all instances? I have a query that I want to be able to set multiple parameters on but give the user the ability to select as many or as few parameters as they want to see. 2 of the parameters are number fields and 2 are text fields with no spaces.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved