how to insert a date stamp into a table when a row is added automatically - excel

I am wanting to update a table we have for outstanding issue in one of our projects so the date of issue being raised field is prepopulated when a new row is inserted in the table. the reason for doing this is I'm aware users occasionally will miss this field when adding data to the table and when going back it is hard to remember when you you raised the issue in the first place.
VBA is not my strong suit but I understand just about enough to get by and know the code I need for inserting the timestamp into a cell and just need to work out how to direct it to the right part of the table but that shouldn't just need to point it to the last row of the table and the column can be feed by its header.
What I'm more stuck on is how I get this done without having the user notice so no need for a macro button to add rows etc. I believe this should be doable using the change event handler but I just don't know enough about how I'd set this up. any advice would be appreciated
if you require any sample code I'm working or a mock up of the table let me know and i'll pull something together.

Related

Table doesn't expand when adding new data (from .csv files in my case)

Lets say I got some external .csv files which I got updated and I just need to hit the refresh button in Power Query to make some magic - that works fine, BUT, there some columns which are information about some parts, and I need to lookup values for them in another .csv file. What I did here is, I didnt convert all 4 Columns in a Table, but I separated them, each column has another name (table name) because I had some issues with refreshing from Power Query, and seemed easier to do calculation first and then convert to table.. maybe that was not smart tough??
My question is and issue actually, I am not getting new rows with new data beneath my "tables" I must drag it down to populate. Why that occurred?
These are functions I used from starting Column:
=INDEX(Matrix[[#All];[_]];ROW())
Then others are just lookup ones depending which info I am looking for:
=INDEX(variantendb[Vartext];MATCH(C2;variantendb[Variante];0))
And last column and calculation is concatinating to have Info name and Code together:
='0528 - info'!$D2 & " "& "("&'0528 - info'!$C2&")"
And of all of them I made in 5x Tables SEPARATELY, not as one table. Maybe I should do with one table, and then do the calculations and then it will be dynamically updated?
It is automatically updated only when I add new data somewhere in the middle of .csv but not when is in a last row, then it is not expanding!
Well, I solved it. How? Using Power Query at its best, I played around and actually gave me complete another approach to my problem, using Merge function and a bit of formatting. Works flawlessly, with minimum functions afterwards. What is important it refreshes in a milisecond - PROPERLY!!!
I am amazed by PQ and its functionality.

Set specific height for all existing/new rows of a table

I have used Excel for quite some time now but only using traditional formulas. Now I am trying to create a more elaborated document for my business using VBA coding to expand my possibilities.
I have done some research and started practicing but found something that I can’t understand how to do yet.
I have a worksheet with a table on it. Since this is a fresh document it has nothing but the header and a blank row below it. What I always did when writing the information was type text in any of the columns that belong to the row immediately below the table (without actually inserting a new row myself). This creates a new row for the table where most of its format is kept, such as text size and formulas. However, I noticed that the row height doesn’t automatically change to that of the previous rows of the table, and changing it manually for each new row is very time consuming.
I would really appreciate it if anyone could share me the necessary Excel VBA code to fix this issue. I have thought of two possible approaches. The first one is a code that automatically sets all the rows of the table to a height of 20 (I want all rows to be the same size so no problem with that), supposing this would also affect new rows as I add them the way I mentioned. The second one would be a code that automatically sets every new row of the table to a size of 20. It doesn’t matter which one you choose, the easiest will be just fine. Thanks in advance.

MS Access - Data in top row appears and disappears when focus on the cell changes.

Its a bit of a weird one but I have a linked table within my database. The table is an excel table with identical field headings and data types and until recently has worked fine however now when I traverse the linked table in Access the data will change every other move, changing from the original row to show data in the row below. Iv had a script output the values of the top row and it displays normally however I cant append this linked table into anything and I assume its this glitch.
Im stumped and would love any ideas as to how this happened and how it can be fixed.
This is an unusual post as I've never quite heard of this type issue. To sanity check things I would suggest that you delete your excel table from the navigation pane in Access - and then relink it.
So then perhaps I didn't understand, and I am wondering what is meant in your first post by: "The table is an excel table with identical field headings and data types"
A link to excel is a qualified "table" so to speak. You should be able to double click on it within Access, it opens in data sheet view and you see all the data but you can't write to it. You can't write back into the excel.
You can query it....
You can append the query results of the excel into a true Access table.

Excel 2010 check cells in a row contain data before the Selection Change fires

I have an Excel 2010 data table which is driven by a query from MSSQL. The underlying query changes depending upon what options the user selects in the Excel workbook. I'm okay with changing the query and pulling the data.
After the data has been selected multiple users will be able to edit and append data to the Excel table and these changes will post back to the SQL database table. Due to the database table structure some of these cells within a given row are mandatory before any data can be inserted into MSSQL and/or potentially updated.
So what I'm trying to achieve is checks on whether certain columns in a row are blank after a cell is edited (I can do this via Worksheet Change) and also before they move off that row so I can bring up a message if all mandatory columns haven't been entered. I can't see any events that fire before Selection Change. My only thoughts on a workaround is to have a global variable row marker that is updated on Selection Change, i.e. it will store the previous row number. I can't use Excel's standard data validation functionality looking at blank cells because although this is fine for a currently correctly populated row that is being edited, inserting new rows or appending directly to the bottom of the table will constantly error as all those mandatory columns will, of course, be blank. Currently I am using conditional formatting to at least highlight columns/cells that require input although this doesn't force users to actually do it. Data cannot be stored within MSSQL until these columns contain data so if they don't fill them in and refresh the table for whatever reason, whatever they have entered will be lost. Obviously this is bad, m'kay. I am concerned about both the Worksheet Change and Selection Change events constantly firing and how that will affect workbook performance.
Any suggestions would be appreciated. Maybe I'm going about this all wrong so any ideas to make this more efficient would also be well received. The user base do not want to see UserForms or MS Access even though it would make this activity very easy. They are too used to the look and feel of Excel sheets.
your best way is to copy the table into 2d array or some other data structure in memory such as dictionary or collection. and than manage each change in memory. this one is very efficient but requires a lot of code. with excel the only problem you have is the key the rest is vlookup and true false questions. vlookup will find the original value and then you have current data + previous data + the logic... is the new data ok?

Import Excel to SQL Server with Insert and Update Using Entity Framework

I have an excel file and I want to import the excel file basing on the existing database table using entity framework. Right now I firstly convert the excel sheet to a DataTable and have a loop to loop through each row of the DataTable. Each row has an id field and if the id exists in the database table I need to update it otherwise I need to insert this row to the database table. I want to use entity framework to wrap my loop into one transaction for roll back purpose in case of error. But I run into a scenario of two rows with the same id but different values. The first row is checked and added my entity collection, but the second row might be mistakenly updated the firstly added row because the firstly is not actually added due to the delayed context.SaveChanges() called after the loop. How can I update the previously added row in the entity collection without repeatedly calling context.SaveChanges() inside my loop? Thanks.
I don't think I have done it over the past decade or so, but I have used Microsoft Word's Mail Merge to create the SQL statement that I needed (SELECT, INSERT and UPDATE) for each line in an Excel sheet. Once I got the long SQL statement in text I simply copy-paste it into the console and the statement was executed and the job was done. I am confident that there are better ways of doing this but it worked at the time with limited knowledge but a need. This answer is probably in the category "don't try this at work, but it is fine to do it at home if it does the job".

Resources