I have a worksheet with 7 columns and I would like to read this into a 2d array. The worksheet can have as much as 50k rows.
1) is it possible to read 50k rows into a 2d array?
2) is it more efficient to read data into an array for access/manipulation as opposed to a worksheet?
3) can someone show me how to read in a worksheet with 7 cols to a 2d array?
I have a workbook with about 700 rows and about 40 records on each row. about 2-7 a day of these. The procedure I currently use a loop for does 2 different things.
1 I collect only a few of the records from the line and place them in a separate sheet .I collect the individual data, identify the ID ( cell F) and then search for the corresponding ID on a nother sheet when I do find it I add the info to the sheet on the last + next row. (I sort later)
2 I collect the entire row and place it on yet a nother sheet. The whole row has information that is categorised by the content of Cell A (name) so I copy the row and paste it into a separate sheet.
What I would idealy like to do is to copy the entire source sheet into an array once, and then copy the data into each target sheet using a loop to get each record from the array. Using only 1 loop to first read the separate data from the " array row" and place it into the first target sheet (procedure 1) and then switch the workbook and copy the whole "array row" into the target sheet there (procedure 2).
At the moment I read info on 1 row switch to the target sheet and place the information there, then I "copy" the row and switch to the next workbook and paste it there then I go back to the source and do the next row.
Obviously Im no programer and that was the best way of doing what I didnt know how to do better .
Is there a way that a whole row can be stored in an array and then 'copied' onto another row on a nother sheet without reading in the individual cells into separate elements. That would be the worse case scenario but a much faster way of doing what I curently have.
I am trying to create a "macro" that will read values from one workbook into an array based on a key field. If the key isn't present the cells data is not to be stored. After the records are stored i want to test them agains a range in a differnt workbook. If the data compared matches a stored value, leave it alone. If there is no match, a cell needs to be added with a value stating a differnce.
Like i stated i am new at this and have no clue how to compare an data array to a field. Let alone read the values into the array.
I made the formula work great, however I want to cut it down and simplify it and make it easier to manipulate... as opposed to having the filename written every so many times.. replace with a loop instead.... so:
Private Sub Weeklytestt_Click() Dim varCurDate As String If DateYesterday.Value = True Then Answer = "1" If DateToday.Value = True Then Answer = "2" If DateTyped.Value = True Then Answer = "3"
Select Case Answer Case Is = "1" varCurDate = Format(Date, "yyyymmdd") varCurDate = varCurDate - 1 Case Is = "2" varCurDate = Format(Date, "yyyymmdd")..........
code to pass a range say (A1:A3) as an arguement among other arguements to a custom function and then reading this as an array inside the custom funtion
I recently added formulas to the attached worksheet where a cell is linked to a "true" and a "false" which are linked to check boxes. When "true" is activated the cell with the formula will = "HOLD" and when "false" is activated the same cell will ="RELEASE". Now, when i saved this worksheet and tried to reopen it a dialog box popped up that said "the content is not readable.... excel will try to recover the content" (or something like that) so when i click "yes" to the dialog box then the sheet opens fine , however, when i save the sheet the same box pops up? Maybe there is something wrong with my formula because before i inserted the formula to the sheet the sheet worked fine.
I have setup a userform to record fuel issued to vehicles. I have a text box which I would like to use to display the last meter reading from my fuel pump. This data is stored in the last cell in column F of "Sheet1" workbook. Is it possible to read this data into my userform so when it starts it displays the last pump reading?
I have a lot of conditions, so I'm wondering whether there's any way I can read the the conditions from cells on a worksheet, so I don't have to type them in manually. In other words, I'd like to have the things inside the "{ }" be cell refrences.
I want to read data from Notepad into Excel. I found this code on the net and have been trying to modify it for my needs:
Sub ImportText(FileName As String) Dim X As Long Dim FileNum As Long Dim TotalFile As String Dim Lines() As String Const DataRowStart As Long = 1 Const DataColStart As Long = 1 FileNum = FreeFile Open "C:...data.txt" For Binary As #FileNum.................
This pastes the contents of each line into 1 cell but I want to paste each value into a seperate cell. So in the attached data.txt there are 5 records each of 2 lines. For example in the 1st record I want to paste 05-693-1900 into 1 cell then 0040 in the cell to the right of that, Town A into another cell, 000000 into another cell....and so on. For the 2nd line it should be 000000000033 into one cell, AA28816 into the adjacent cell...and each remaining number into a seperate cell. I also want to leave 3 blank lines before going to the next record.data.txt
I'm trying to open a file on a network drive...but I'm getting the following error message when it opens: "This file may be read-only, or you may be trying to access a read-only location. Or the server the document is stored on may not be responding." Now, the file itself has no rights restrictions and is not read only. It doesn't appear to be locked.
Now, there are other Excel files in the same directory which I could open fine; however, the Excel documents having the above problem all have a little black icon "appears to be a padlock" (image attached) at the bottom left hand side of the Excel file icon. I tried the following:
- Renaming - Converting to a different file format (didn't work, it won't let me) - Opening in notepad...etc doesn't work.
This file is dated back in 2004...do you think it's corrupt? Is there anything i can do to open or recover this?
I have four worksheets in my project and I would like to protect one of the sheets so changes can't be saved. In other words, I would like to make that specific worksheet "read-only". The other three sheets I want changes to be saved with the document.
Subscript 9 error that Ive been getting when I run this macro. It has worked in the past, but when I tried to test it today I keep getting errors on the array portion.
I'd like to "dump" an array onto a worksheet. It's called MyArray, it's varying in length, 7 "columns" wide, and I know the uppermost left cell I'd like to dump to.
I am trying to populate name a worksheet and select it via values produced from an array. I don't know how to change the value produced from the array to select a worksheet.
Dim arrayTypeCount As Integer Dim arrayTypeName As Variant Dim awaitingSheetString As Worksheet arrayTypeCount = 0
I've defined a string array and would want to use it as a basis for a vlookup. Is it possible to find the elements of the array directly in the worksheet ?So far I've got :
I'm trying to sort an array which is of variable height/rows when put on a worksheet. I need to sort by column C ascending (smallest to largest) and then by column D ascending (oldest to newest). I tried recording a macro but the code is just junk.
Code:
Dim BookSPSortingWorksheet As Worksheet Dim TR As Range Set BookSPSortingWorksheet = ThisWorkbook.Worksheets.Add Set TR = BookSPSortingWorksheet.Range("A1").Resize(UBound(array_book_SPNames), UBound(array_book_SPNames, 2)) TR = array_book_SPNames
Is there a way I can use the sort function like the below by indexing my TR range for columns 3 and 4?
Below is the syntex I am using in the array... and the source file.. when opened will calculate the values. The problem arises when I close the source file and values return to this " #Value". My entire frontend file is nothing but arrays and links compiling data from multiple sources and everything works except cells that have the below array in them.
why my cell values will not save upon saving and closing both my frontend file and source file?
I am looking to write a macro that can look at a value (i.e. "X") in a cell and compare it to the elements in a 2D array (where one dimension corresponds to the start value and the other to the end value) that is found on another worksheet. If "X" falls between the starting and ending numbers then I would like the macro to return a string (say "Test1") to a cell on the same row and a couple of columns to the left. The string values are listed to the left of the start and end values on the first worksheet and are elements to a 1D array. I am trying to make this " loop" through all the cells that contain run numbers (I have highlighted the columns in yellow on the attached workbook). There are multiple (i.e. +12) worksheets in this project but I have only included two in the sample I am providing because of file size.
Rather than looping through a multidimensional array to populate a worksheet, is there a quick function which can export the entire array to a worksheet?
I have an array with dimensions (5000,30). I want to perform a worksheet function "Percentile" on specific columns within the array. So for instance I may want to know the element falling at the 50th percentile in column 5 of the 30 column array. Is there a way to do this without having to place the array onto a worksheet?
Working with an existing macro from this forum. How do I create the array showing the number of sheets found? I know from a MsgBox that two sheets are found.
I have a workbook that is doing something I don't understand. In several places I am using arrays to transfer/modify information, then placing the array back onto the worksheet, and this works perfectly. The following code... doesn't.
(I've cut out unnecessary code like variable declarations - all my integer items are declared as Long)
Code: Dim varA As Variant, varB(10000, 1) As Variant Set wkDest = Sheets("a") erB = 0 For lpTerm = 1 To 4
[Code]...
and several other ways. What happens is just null output, a full column of nothing. However, when I expand my worksheet range to two columns, all the data from varB appears - it is shifted down one column and row. So my data starts at .cells(2,2) instead of .cells(1,1). The data is all perfect, I've verified it left and right.... I just can't figure out why it's getting shifted like this.
How can I write a piece of code to initialise an array with all the worksheet names. I cannot be sure how many worksheets will be in the file as it generates different numbers each time.
I used to just declare with sheet names, but I can no longer do that.