I am creating an Excel spreadsheet in Access vba code. I need to change the column names from A, B, C, etc to a meaningful name. I have looked high and low but cannot find a way.
The column names in Excel cannot be changed. They are a fundamental part of how Excel operates.
When creating a spreadsheet based on a database table (sounds like what you are doing), the first row in the Excel spreadsheet will contain the field(column) names of your data. That way, when you need to read the data back into Access, or import the spreadsheet as a table; Access, by default, knows to look in the first row of the spreadsheet for the column names.
If my memory serves me correctly, I don't believe that you can change the Column header labels from the default A, B, C.
You could write the header names out in the first row of the spreadsheet
After import Excel to Access i change the column header using:
CurrentDb().TableDefs(TableName).Fields("OldName").Name = "NewName"
Solution found in here: https://movefirstblog.wordpress.com/2008/10/08/access-vba-change-the-name-of-a-field-in-an-existing-table/
Related
Need advice on the following; Thanks in advance.:
Excel, the visual description of the issue
Further description of the issue:
certain Product code = certain Product name of certain Size.
The help-table on the attached image shows that a certain product code = what product name of what size, as a guide.
This is what I try to do. This is what my question is: How to achieve:
Manual entry in cells of column A should trigger automatically filled content in cells of columns B and C based on the content of A and based on the dependencies described in the help-Table.
Edited: As the user proceeds adding new records in new rows, the appropriate columns (B and C) should "fill itself" automatically as soon as there's an entry in the same row in column A. This automatically filled content in column C and B depends on what is the content of column A as can be seen on the attached image("help-table"). And all this should work without me using a formula in columns B and C.
So far I used an "IF" formula which is not practical for many possible product codes.
A formula is also impractical as its usage requires the formula to be copied to next row, which I want to avoid. I want the set rule to be applied to a whole column.(for example as the data validation or conditional formatting work in excel)
It would be ideal to use it in a way like the conditional formatting works, but in this case it should work with values(content) instead of colors and should be applicable for an entire column without a need of copying to the next row. That means I'd like to avoid macros or VBA if possible, just want to use built in features.
I already use Defined names and Data validation for columns A,B and C which works for me as a choice list and also to control column B and C for allowed entries only, so their content is not mistyped and has the strict format needed. Excel 2010 -if that matters.
Important: there will be 1000's of rows added, I just made a short description above
Formula for cells in column B:
=IF(A2=10,"prod1",IF(A2=20,"prod1",IF(A2=30,"prod2",IF(A2=40,"prod2",""))))
Formula for cells in column C:
=IF(A2=10,"50",IF(A2=20,"75",IF(A2=30,"10",IF(A2=40,"50",""))))
Also tried a CSE formula for the entire column B or C like follows (but the file size was couple of MB which is not desired):
=IF(A:A=10,"prod1",IF(A:A=20,"prod1",IF(A:A=30,"prod2",IF(A:A=40,"prod2",""))))
If the entry in column A will be only 10,20,30 and 40 then use OR formula in column B
=IF(OR(A2=10,A2=20),"prod1","prod2")
In Column C we can reduce two IF
=IF(A2=20,"75",IF(A2=30,"10","50"))
And regarding the file size please save it in binary format. Hope this will help :)
We sell our product via a number of different retailers. These shops send us reports of what they have sold and we need to import this into our new stock management system as a master file.
The stores do not and will not provide the data in a uniform way based on our desired template.
I therefore need a way of consolidating ranges of data that without having a unique ID for each line, with minimal manual formatting from the data importer to help save time.
http://s14.postimg.org/arslbnnxt/excelconsolidation.jpg
As you can see in the 2 examples above, nothing is in the same order and some of the supplied fields haven't been used. The column headers are static, only the data is actually pasted.
I've tried using the Excel Data consolidation tool but the SUM function just wants to add everything up or simply reports a single value, I've played with Vlookup but I then need to dedicate a number of rows to each store which results in lots of empty rows.
If you can point me in the right direction I'm more than happy to research the tool or function I need, web searches keep bringing me back to the consolidation tool.
Many thanks,
Since you say that column headers are static, you actually do have a unique ID.
The task can be accomplished by using HLOOKUP with Column headers as lookup value.
However, the formula will depend on how you organize or store input sheets from different stores.
Here I have tested a setup where each store input is pasted in consecutive sheets starting from 'Sheet1'. i.e. Store1 in Sheet1, store2 in Sheet2 ... with row 1 containing header.
Then in consolidated sheet using helper columns for identifying sheet and row number, the formulas look like this
in A2 =IFERROR(HLOOKUP(A$1,INDIRECT("Sheet"&$H2&"!A:O"),$I2,0),"")
in H3 =IFERROR(IF(INDIRECT("Sheet"&H2&"!A"&I2+1)="",H2+1,H2),"") (if no more records, increment sheet number)
in I3 =IFERROR(IF((H3-H2)=0,I2+1,2),"") (if sheet number changed, reset row number to 2)
Initial value for H2 = 1 , I2 = 2
Test file: Storefile
I have the following:
1 Access file with a big list of items that people can order.
1 Excel file with 2 tabs.
In the 2nd tab of the Excel file I import the Access table.
For each row I have a dropdown list in the first column with the values of the first column of the access table.
In the 2nd column of the first tab I use VLOOKUP to show the price linked to the item of the first column.
In the 3rd column of the first tab the user can fill in an amount.
Here's the catch:
in the 4th column of the first Excel Tab I want to show a total so B * C. Nothing hard about that. But I want this value to NEVER CHANGE.
So even if the Access database is updated I do not want the value of the already calculated cells of column 4 to change.
I know it seems pretty unlogical but I really need this.
Any suggestions? Is there a formula that I am missing?
EDIT from post:
The file is to be used be other people than myself. If paste special can be done automatically as in like a formula it would help but that doens't exist or I haven't found it.
Thanks in advance.
If the formula is linked to a connection (e.g. OLAP cube, a table that is linked to an Access table) then remove the connection before sending the sheet out. See link.
If you distribute the workbooks to people who do not have access to the data itself (not on your network) the issue will solve itself, take away that some dummies will complain about their data disappearing not refreshing.
The formula you're asking for would refer to itself once it has a value, confer circular reference.
If used by your close enivronment you might want to have a VBA snipplet insert your formula and then do the PasteSpecial method automatically (you'll have to enable macros on each of the computers involved in this case).
Need some advice, I have a large excel sheet that I need to break up by a value in column B. The kicker is in some cases i need more then one value from column B. Example I might want A and B together and C on its own. I have another workbook that has this mapping. I'm stuck on 1 Best tool for this job and 2 how.
In Excel im not sure how to make this work. I know i'll need a loop to go through the list, but how do i handle the ones that need to be combined?
In access I was thinking a table for the data and a table for my package list. The create a query and loop the values into the query using VBA.
I assume you want to break your main sheet to multiple sheets based on value in column B.
You can make use of excel vba dictionary
Does VBA have Dictionary Structure?
You need to load the workbook that has the mapping into the dictionary as below:
Key = 'value in column B'
Value = 'name of the sheet where you want that data to go'
Loop through the sheet containing the data get the value in column B, lookup in the dictionary to get the sheet name to which this data should go. Write the data into that sheet name.
Hope this helps.
I have a spreadsheet that will occasionally get new data that I don't know the contents of, I just have to add it to the spreadsheet. Some of the new data is just updating rows that are already in the spreadsheet, and other data is adding new rows. I'm looking for a way to add a column that will tell me if something has changed in the row when I compare the old spreadsheet to the new one.
The sheets have one column that will always have a unique value among all the rows, so I can use that to match rows if the sheets aren't sorted the same way. Here are some screenshots to show what I'm trying to do:
Old Spreadsheet:
New Spreadsheet:
The only solution I can think of is a large nested IF formula that compares each column one by one, something like:
=IF(Old!B2=New!B2,IF(Old!C2=New!C2,"NO","YES"),"YES")
The problem with that is that it gets very hard to look at since my actual data is using 33 columns (not including this "Changed?" column) and new columns could be added in the future.
I'm not very technical with Excel, nor have I ever used VBA, so I apologize in advance if there is a simple/obvious solution that I'm missing.
Thanks in advance for your help.
Using your example, in the 'New' sheet cell D2 and copied down:
=IF(COUNTIF(Old!A:A,A2)=0,"YES",IF(SUMPRODUCT(COUNTIF(INDEX(Old!A:AG,MATCH(A2,Old!A:A,0),0),LEFT(A2:AG2,254)&"*"))=SUMPRODUCT(COUNTIF(A2:AG2,LEFT(A2:AG2,254)&"*")),"NO","YES"))
vlookup would also work well for this problem.
in D2, the formula would be:
=IF(AND(VLOOKUP(A2,Old!A:C,2,FALSE)=B2,VLOOKUP(A2,Old!A:C,3,FALSE)=C2),"NO","YES")
The column numbers (2 and 3) are the columns that correspond to the data you are trying to match, using the ID column.
It's possible to find the appropriate column using MATCH if the column names you have match the column names in the old sheet
This would make the formula look more complex, but Excel would adjust the Old!A:C reference if more columns are inserted.
The formula would look like this to match against column names
=IF(AND(VLOOKUP(A2,Old!A:C,MATCH($B$1,Old!$1:$1,0),FALSE)=B2,VLOOKUP(A2,Old!A:C,MATCH($C$1,Old!$1:$1,0),FALSE)=C2),"NO","YES")
The difference between this and the last one is the use of MATCH($B$1,Old!$1:$1,0) to find the column (using $s to anchor the lookup values)
In this case, specialized software for Excel compare is better.
My company use this software. Check it out.
http://www.suntrap-systems.com/ExcelDiff/
http://www.youtube.com/watch?v=QQgnWr_RT-8