Moving VBA Generated List Between Columns And Setting Arrays
Jun 21, 2013
I have been working on a few different spreadsheets, and I have gotten almost everything to work. There are just two things that I just can't get right. Here is the first problem:
It seems to me that I should be able to change where the list will display where it says: sh.Range("a10").PasteSpecial xlPasteValues
I change the range to anything in column A and it works, but If I change the column, the entire script seems to run in one row, and the days of the week don't move.
Code:
Sub Workbook_Open()
Range("a2:d300").FormulaR1C1 = Clear
Dim sh As Worksheet, dyArr As Variant, rng As Range, c As Range
Set sh = Sheets("Summary")
[Code] ....
Now the second issue, I need to know how to set the array to look at every single worksheet without listing every sheet. Here is an example:
Ok what I am trying to do is lookup a value in a table (kinda like one below but alot bigger). What I plan on doing is creating a drop down list for the rows that show "A, B, C etc) and then another drop down for (AA, BB, CC etc).
So lets say the 2 drop-down list are set to C and BB I want to be able to fill another cell with the value -134
I would use If statements but like I said the table would be alot bigger than example. If possible I would rather not use VBA due to work security settings.
a b c AA-110-110-129 BB-115-115-134 CC-117-133-136
I am retrieving a CSV file from the net. In this file there are 'x' amount of row data and 7 columns. I only care about the values in the 7th column for each row. I also don't care about the entire first row. A graphical version would be represented something like this, with the values I want colored in orange:
I've managed to dice this thing into a jagged array by first splitting it using vbLf as a delimiter, and therefore adding those to an array called Lines(). Then I split Lines() up using commas as the delimiter and threw those into a jagged array, let's call it Breadcrumbs()(). I want to throw all the values from Breadcrumbs(i)(6) into an array of its own. Here's my code so far:
Code: Public Sub CSVparser(file As String) Dim Lines As Variant Dim j As Integer Lines = Split(file, vbLf) ReDim breadCrumbs(UBound(Lines)) As Variant For i = 1 to UBound(Lines) - 1 breadCrumbs(i) = Split(Lines(i), ",") Next i End Sub
I have a large database of research data where the first column contains different categories (labelled as I, II, III, IV, V, and VI). For each row there is a data value in the second column that is numeric. What I need to do is move the data so that the data are displayed in 6 columns with the data values listed each column heading according to the category label. In the example I've shown there are 6 different categories, but the number of categories (and hence the number of columns in the final resulting sheet) will change for different data sets that I'm using. Also note the the number of cases for each different category is different (so that each column will not be even in terms of the number of rows of data under each column heading). I hope I've been able to explain what I'm looking for clearly.
I've attached a sample file showing the sample data input that I have on one sheet, and then the desired re-tablulated outcome on the second. I have done this using the auto-filter function and copy/paste, but this will take far too long for the larger datasets I'm working with.
I have drop down form control called “V_bar” on spread sheet “Parameter table”. Using following VBA routine to populate list values from the range on another sheet named “Data table”
I'm trying to programmatically set the value of a combobox but I'm running into errors if the combobox list does not already contain the value I'm trying to set it to. How can I first test if the combobox has that as a valid option and, if not, add that item?
I have requirement wherein, I have to put filter conditions on two separate columns in the same sheet & putting hard coded value eg. "XYZ" in third column for this selected range. I am using macro autofilter but its giving me errors for multiple filters.
I want to automatically set default values in a row dependant on the value chosen in a list. Some of the default values need to be lists where the user can chose to update to a non-default value.
I have tried using a double drop down list. However if the default list value is changed then the dependant list value is changed, the default list is not automatically updated.
I need to create "Define Name" references for 70 columns of data so that I can establish Parent/Child relationships in a data validation list. Is there a quick way to do this or do I need to go through the same steps 70 times (i.e., once for each column)? My concern is that the current order of my columns might change too, and I don't want to have to recreate the "Define Names" every time it does.
Using VBA... I have Column N (eFIUnitRebate) which I want to swap with Column M (FFUnitPcnt)
Now with Column M as eFIUnitRebate and N as FFUnitPcnt I want to create an extra column (adjUnitCost) where Column N is and push FFUnitPcnt to become column O, etc.
Here is how the whole process should work: Swap M and N Insert new Column in N Insert new Column in P Insert new Column in Q Insert new column in R
There is more information on the sheet after these columns so for all column inserts it needs to push whatever was there over.
So the layout is as follows: J K L M N O P Q R
Units UnitCost UnitRebate
[Code] .....
These columns are thousands long, so I would like the formulas for them to be applied to the whole column as well.
I'm trying to create a code that when run hides a selection of columns and defines the minimum and interval value for a chart on the active worksheet. My attempt is assigned to the 'update skills' button at the top of the "GRAPH" worksheet of the attached workbook.
I need to be able to locate some important columns in a table of raw data (the column locations are not fixed).
I would like to identify the locations (based on the heading values in Row 1) and store them as Public variables. The Match function works fine for this, however I'd like to make a simple loop to set these variables (opposed to repeating the function for each).
In the example below, I can't figure out how to reference "List1(Count)" as the name of the variable I'm trying to set.
Code:
Public Field1 As Long, Field2 As Long, Field3 As Long 'The column numbers will be stored here Sub FindFields() Dim List1(3), List2(3) Dim Count As Long 'Public variables (declared above)
[Code] ......
So after running FindFields(), the Test1() macro should give "1 - 2 - 3" (for example) as the locations of the fields in Sheet1. But currently this doesn't work.
I am doing a SumIf function on some Imported data a follows "=SUMIF(FMEFactors!B:B,Long,FMEFactors!B:B)". Now, this is fine if the columns are imported in the same order but if Column B data gets moved to another Column the SumIF will give false information. I need to find the correct column to do the SumIF on.
I receive a report which, amongst the other columns of data, has 7 specific columns with four digit codes on each row. I would like to find a way to concatenate these 7 columns into Column A, inserting a - between each code and adding -uu at the end of the last (7th) code.
I wouldn't be requesting assistance at all with this if the codes were always in the same column. Sometimes, they move 1 or 2 columns left or right depending on the additional (unwanted) data in the columns in-between. The column names, however, never change: Code 1, Code 2, Code 3, Code 4, Code 5, Code 6, Code 7
I was wondering if there was a way to still concatenate these columns into Column A but also take into account that the columns shift...
I have extracted a report from a web package into Excel - basically a list of documents held on our website. The Cells in Column B would have the word Title or Description, Column C would have the actual title of the document, Column D would be blank on rows with Title in Column B and Column E has a Document ID (DocID)Number. To make this easier to read is it possible to filter Column B using Title and then move the DocID number from Column E to Column D.
I have attached a shortened version of the spreadsheet with the filter applied in Column B already. The real spreadsheet is 1000 lines long and would take quite a while to drag and drop each DocID number from Column E to D. I assume this can only be done with VBA.
I need to identify values which are less than 0 and move those cells to an adjacent cell.
Acct Desc Amt 2100 Acct1 -10 2101 Acct2 10 The -10 cell will move one cell to the right. I have an imported list with gl accounts, descriptions and amounts and want to have the negative values moved to a new column.
I need to line XYZ to XYZ as well as the information attached to XY&Z i dont really know how else to explain it but i was hoping there was a macro or something out there that i could use to do this would make it a lot easier
I am running through some old accounting documents in excel 2003 (originally from SAP), that contain information in row form that I would like in Column form. Column E indicates to me whether this was an invoiced amount or payment amount or "other." I have limited VBA exposure, but am fairly proficient at what I do know. This is just too difficult for me!
Where the "Assignment" #'s are equal, I need the script/macro to move "up" YP's, YQ's,
See Original Layout.jpg Then What I'd Like.jpg Then End Result
I have the following spreadsheet with 4 columns of data:
1000001245aMr Fred Blogs 1000001270a1 Blog Street 1000001270bNorwich 1000001270cNorfolk 1000001270eNRx x99 1000001270gThe Manager 1000001270k01603 555 555 1000001270l01603 555 555 1000001270qManager 1000001270xN 1000001270yN 1000002245aMrs Fredilina blogs 1000002270a10 Blog Street 1000002270bNorwich etc etc for about 36,000 rows.
What I need is for each unigue reference ID (column A), I need all corresponding data moved up into a single row in serperate columns, something like this:
1000001 |245|a|Mr Fred Blogs| 270|a| 1 Blog Street|270|b| Norwich | 270|b|Norfolk |etc 1000002 |245 |a |Mrs Fredina Blogs |270|a|10 Blog Street |270|b|Norwich| etc
Each entry doesn't nessesarily have the same number of rows.
I would class myself as a beginner VBA bod, but the solution to this one is illuding me a present.
Without moving or copying columns I need to print Column A & Column I on the same piece of paper and not print Column B-H.
Every time I try this though it is printing column A on one sheet and Column I on a second sheet. Yes I've checked margins, etc.
This is actually possible, right?
(I didn't want to move or copy columns as the spreadsheet is for someone else's use, plus my formulas buggered when I tried to so I didn't want to add that complication for the other person of double checking the formulas every time she wanted to print this two column version of the sheet.)
i have data that has several bits of information for each different account number. is there a way of writing a macro to transfer the information from the main sheet onto different sheets automatically titled for each of the different account numbers?
ie. Account Cost E1 100 E1 200 E2 E2 etc
i want different sheets for the info next to each of the account numbers
The average of the first 10 cells is now AVERAGE(A4.A13) = 5.5
I would like to enter one formula in say cell A1 that will calculate the moving average in the first ten cells each time a new entry is added. Naturally as needed, new rows are added below cell A1. I hope my problem is clear.
as I have been unable to solve it myself. I have tried using offset but have been unable to resolve the issue.
I have address data all in column A (each paret of the address is on a separate row) which I need to move to separate columns on one row for each address:
ie:
Mr Bloggs (row 1) 123 The Avenue (row2) The town (row 3) The postcode (row 4)
Mrs Smith (row 6) 456 The street (row7) The postcode (row 8)
needs to be: (I have used || to indicate different columns)
Mr Bloggs || 123 The avenue || The town || The postcode Mrs Smith || 456..... || .......
The problem you see from the above is that they are not always consistent ie. the postcode (zip) isn't always 3 rows below the name for example. Also although generally there is a blank row between each record (this may sometimes be 2) and equally there may also be times when there is a blank line in the address.
Any ideas on how to do this.... I have 1000's of records and really can't afford to go through each one making it consistent before moving it to columns?