Avoid Hard Coding Range Reference
Oct 5, 2006
I now can open all the workbooks in a filefolder and look at each of the sheets in each file and build an array to consolidate a range from one sheet to another. The problem is that the one range is hardcoded in the script (because that is what I was using to test.) I have written code to build an array of 66 rows and 5 columns that are stored in a worksheet in a named range.
how arrays work so I can use both of these arrays - one array ConsolParams(), to identify the range in the Sources part of the consolidate statement. The other array MyArray() stores the sheet names. Actually ConsolParams also stores "to" range now hardcoded as "J11".
Option Explicit
Private Sub cbConsolidateToRollups_Click()
Dim MyArray() As Variant
Dim Source As Variant
Dim sToPath As String
Dim sRollUpWB As String
Dim sRollUpToWs As String
Dim sRollUpFromWS As String
Dim sShtName As String
Dim sSourceWS As String
Dim nShts As Integer
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Dim WB As Workbook
Dim i As Integer
Dim r, c, p As Integer
Dim ConsolParams(5) As Variant
Dim CostType, RangeName, FromRange, TargetCell, TargetReport
Application. ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False.......................
View 6 Replies
ADVERTISEMENT
Mar 4, 2014
Is there any way in VBA to refer to a control in its own event procedure without referring to it by name/hard-coding?
It might be clearer to explain by a dummy code example:
[Code] ......
I'm seeking what I would need to replace Line1 with.
View 11 Replies
View Related
Aug 20, 2014
I am trying to multiply a range of cells by a cell reference. The cells currently have hard coded values in them. I know with past special you can multiply a range of cells by a copied #. I want a similar function to that just instead of a copied cell its a cell reference. No VBA.
View 5 Replies
View Related
May 20, 2007
Is there a way that this can be coded so that when the workbook opens up it turns on the reference to the Microsoft Scripting Runtime library?
View 9 Replies
View Related
Apr 10, 2009
All I need is to use the forecast function =FORECAST(I902,F832:F901,I832:I901) but want to substitute a hard coded from and to value list, such as something like =forecast(71,F832:f901,{1-70})
That is, forecast case 71 given a range of 1 through 70. What is the correct syntax to give a from and to value? Curly brackets don't seem to work, and I don't want to do a list like {1,2,3,4,5,6,7...} which would be a pain.
View 9 Replies
View Related
Nov 2, 2008
I'm trying to write a code which would place formulas in the row just below the my range (normally a matrix of figures) to sum the column in that just above that. Here's what I've got so far but it doesn't work.
View 6 Replies
View Related
Feb 22, 2007
how to count unique records, and I can only find formulas, and not code. This code works fine, and I get the right "actual" count, but I need to change it to a unique values count.
Sub CountEmployees()
lastrow = ActiveSheet.UsedRange.Rows.Count
For t = lastrow To 2 Step -1
If Cells(t, 8).Value <> "" And Cells(t, 8).Offset(2, 4).Value <> "" Then
Cells(t, 12).Select
Selection.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
List = Selection.Cells.Count ' Need to make this unique count
Cells(t, 9).Value = List
End If
Next t
End Sub
View 9 Replies
View Related
May 4, 2007
I have three cells in a column. A1, A2 and A3. There are only 4 possible numbers that these can have in them, 0,1,2,and 3. Here is the catch. None of them can repeat, although they can be in any order. And the column may only have data in the first cell or the first two or all three. Is there a simple macro that will alert me to when a number is repeated? It needs to be a macro rather than a apreadsheet function.
View 9 Replies
View Related
Jun 19, 2008
I have a range (offset based) which may increase by rows or columns whenever necessary.
In that I have data table like this:
HUNONETWOTHREEFOURFIVESIX
100110021003100410051006100
200120022003200420052006200
300180028003800480058006800
400140024003400440054006400
500150025003500450055006500
In the above table I want to enter in another column or row, a number which is not available in the given table (i.e. no duplication is allowed). (This table may grow both column & row wise). If, duplication is there the message box should say that the value already exist. And, if possible, the existing value can be colored with any color, so that we can easily find out where it is.
1) how to name a offset table and
2) how to avoid duplicate value when entered? Is data validation is one solution?
View 9 Replies
View Related
May 20, 2013
This works
ws2.Range("C5").Formula = "=sum(D5:ZZ5)"
guide me on the syntax when the final column reference is a variable
ws2.Range("C5").Formula = "=sum(D5:" & Cells(5, l_LastCol) & ")"
doesn't work
View 3 Replies
View Related
Jul 14, 2014
Is it possible to reference a cells value to define a range reference?
[Code] ......
I am trying to define the row value in the range reference with a value in a secondary cell?
View 3 Replies
View Related
Jul 2, 2014
I am having a problem with excel, specifically a formatting/lag issue. I believe I know what the problem is, but I do not know how to solve it.
The file was too large to upload here, so you can find it in my dropbox.
The issue sheet is labeled Chain. Scroll down to the bottom to see the lag and delay.
After formatting many rows and columns of cells, all of the rows below the useful information has been formatted in different ways as well. This means thousands and hundreds of thousands of cells are formatted and doing nothing.
Just hiding the cells (which they are right now) takes forever, and you can clearly see the lag when selecting cells in the bottom row.
View 4 Replies
View Related
Nov 2, 2008
I have a web query which updates regulaly, however, a lot of information is prodcued which i dont need or want. I know that the information I do want will always be in a single column, usually A or C.
The problem is further complicated. If I have the following search list on sheet1 column A:
Search List (sheet1) Web Query results (Sheet2) Known bad data (sheet1)
A AB AB
B E DE
C F
D A
E B
F C
G DE
I need to be able to search through the information returned by the web-query, and find the first exact match in the returned data that exists in the lsearch ist, so in the above table the first exact match would be row 2 which contains only an E. Row 1 with AB is not a match as it does not exist in the search list.
So, having identfied where the first entry I am interested in (E) is, we need to copy all the cells below it until we find the first entry which then exists as an exact match in Known bad data column.
If all goes to plan, running the macro on the above data would output the following to sheet 1:
E
F
A
B
C
View 9 Replies
View Related
Feb 27, 2009
Has anyone created a marcro that will convert all the worksheets to Hard number, changing the formula results, (by Copying and paste, special, value). all at once?
View 10 Replies
View Related
Oct 17, 2007
i have a column that is seperated by hard returns how can i seperate them into new columns.
can i find replace a hard return and then text to columns.
View 9 Replies
View Related
Nov 14, 2006
I have a string in a cell which is essentially comma separated and want it in the same cell but with enters instead of commas. Cell info to start with would look like this
Bob, The, Builder
And the result I am looking for is
Bob
The
Builder
All within the same cell so I can create a label which uses this information on a user form. I have attached a small example.
View 4 Replies
View Related
Dec 18, 2012
How to "hard code" a cell's fill color? I want to assign a cell's fill color to yellow. While setting the fill color is easily done, my problem is that as soon as I paste data into that cell, it looses its fill color. Is there a way to tell the cell to never change the fill color?
View 1 Replies
View Related
Feb 16, 2009
Need macro that automate our QC department. What the macro does is it looks up the item number based on the barcode that the scanner reads and brings up the item number, the item description, total of units in a case, how much a single box of the item will weigh and how many units in the inner box may be sold at one time. The trouble is that not all items have an image available so that the person who is doing the checking knows what the item looks like.
There is a Logitech webcam setup to take pictures of the items. The following code allows us to import the image of the item into excel in a given cell:
View 5 Replies
View Related
Aug 7, 2009
I have a userform that contains a textbox. How can I insert a "hard return" in the text portion to include a blank line between paragraphs?
View 2 Replies
View Related
Jul 3, 2014
code they have in use for saving emails and attachments to hard drive using VBA. I have found the attached- which is close although it only [URL]downloads attachments. I would like to go through the inbox and download files received on a specific date, from the inbox subfolders to sub folders on the harddrive
View 4 Replies
View Related
Apr 8, 2009
Is it possible to lock a cell so that the user must enter the number manually as opposed to using a formula.
There is a cell on one of our spreadsheets that the user should be hand entering the numbers from the general ledger this is done to ensure that the general ledger balance is the same as the spreadsheets totals. However most of the user insert a formula that just copies the number from above into this cell that should be hand entered.
View 9 Replies
View Related
Oct 2, 2007
Cell A1 is HEAT_CODE
Cell A2 is W5H
In cell
=DMIN(Database,"Cost",A1:A2) return the proper value
I need something like the following so I can use fill down.
=DMIN(Database,"Cost","HEAT_CODE"=A2)
the above returns #VALUE! error.
View 6 Replies
View Related
Jul 21, 2013
I have a range that I named. Let's say that range is called "RangeX". Let's say RangeX is defined by B2:E10
I have a series of formulas that give me the row and column numbers of the starting and ending cell of a subset range I want to create within RangeX. Let's say the starting cell is defined by (1,1) and the ending cell is defined by (3,4) within RangeX. Translated, the starting cell would be B2 and the ending cell would be E4.
How do I create a subset range using the starting cell (1,1) and (3,4) in VBA? I would like to use the row/column reference as RangeX itself could move around.
View 1 Replies
View Related
Oct 21, 2009
I have a workbook with two sheets. The first sheet is the data sheet.
Data Worksheet
A B C D colA colA,B colA,B,C colA,B,C,D
104 20 21 CR10600S 104 10420 1042021 1042021DUS
104 20 21 CR10600SX 104 10420 1042021 1042021DUS
104 20 21 CR10603S 104 10420 1042021 1042021DUS
104 20 21 CR10603SX 104 10420 1042021 1042021DUS
104 20 22 CR49605S 104 10420 1042022 1042022HKZ
104 20 22 CR49605SX 104 10420 1042022 1042022HKZ
104 20 23 CR39601P 104 10420 1042023 1042023SPR
The next sheet is where the magic happens. Separate this worksheet into two sections. The reference section (column A and B) and the entry section (column E-G). Column D is a formula that will concatenate column E-G together. In the entry section any number of combinations can be entered. In the reference section I need to take the style number and reference it back to the data sheet. Then take the possible combinations from that style (column E and greater) and see if any of those combinations exist on the other sheet in column D. If so then say added....otherwise say needed.
"....In Pricing Sheet" is where I am looking to put needed or added or something like it.
A B C D E F G
STYLE …IN PRICING SHEET Concat DEPT MCL SCL STYLE
CR10600S Added 1042021 104 20 21
CR10600SX Added 1042022 104 20 22
CR10603S Added
CR10603SX Added
CR49605S Added
CR49605SX Added
CR39601P Needed
Any ideas on how to do this in formulas and without code? I have tried and looked into index, match, dget and lookup. I just don't think I am finding the right combination of formulas.
View 9 Replies
View Related
Aug 17, 2012
Is there an easy way to populate a combobox with a list of directories on the hard drive?
I want to create a way for a user to specify a file without having to type in the full address by hand.
I would like to start in the c:/ root and list the directories in one combobox and the excel files in another combobox. Then if they select say "desktop" it displayes the directories in "c:/desktop" and the excel files contained there in. Then if they click test it does directories in "c:/desktop/test" and so on.
View 2 Replies
View Related
Oct 8, 2012
We have multiple macros that have been developed by various users in the company. Many of these macros have file paths hard coded into the macro to reference file locations with networked drives.
We are planning on making some changes to the network file structure which will break these macros. I realize we will have to go in and manually change all these. I want to ensure that the end users have the flexibility they want, but not have to touch each macro if/when folder structures change, or files migrate to SharePoint etc.
ini files, master reference Excel file...,
View 3 Replies
View Related
Sep 7, 2004
I have a spreadsheet that was an export from an old program. The ý symbol indicates the start of a new line within a cell, is there an easy way to do a search for the ý and replace with a hard return?
View 9 Replies
View Related
May 28, 2008
Assume a workbook with some nice pictures.
How do I save all of those to D:TEMP on my Hard Disk ?
View 9 Replies
View Related
Apr 15, 2014
Is it risky for someone to edit an excel document while it is still in the flashdisk or external hard disk? I was told that this habit can lead to loss of data or the data can be affected if someone does this. I was told that I have to copy/cut paste the document onto my desktop, edit/ work on it then move it back to the storage device. Is all that work necessary, or can I simply work on the document while it is still in the flashdisk or external hard disk..
View 6 Replies
View Related
Apr 26, 2013
If I want to improve my excel performance like ability to open multiple excel and sheets to perform calculation, should I change to a SSD or a faster intel chip? My current PC sometimes give me a black screen for my excel sheet or is unable to save certain sheets when I open too many sheets.
View 3 Replies
View Related