Insert a Row to a Specific Set of Columns - excel

I'm working on a spreadsheet to act as a master copy for some important information that will be kept track of for a project. On the main sheet I have a table for notes and a table for contacts set up separated by several columns and some VB code to insert new notes or new contacts. However, when I insert a new note I want it to appear at the top of the table and to move all existing notes down a row. Is there any way to add a row to a specific set of columns so that any other data that is kept on cells with the same row, but in a different table, are not moved?

A basic example:
Dim rng As Range
Set rng = Worksheets("Sheet1").Range("A2:D2")
rng.Insert Shift:=xlDown
...assuming that you want to insert 1 row of cells above the cells currently located in A2:D2.

You'll have to code a VBA macro that selects all cells in the notes table as a Range object, and then moves them down one row.
I wouldn't know the exact code, but I'd advise you use the "Record Macro" function and do it by hand: select two cells in an Excel sheet, press the right mouse button and click "Insert". Then it'll ask you if you want to move the rows down. You can see in the newly recorded macro what the code is, and adjust it for your specific purpose. Good luck!

Related

Use common dropdown across multiple worksheets to change single cell

I have a large file with a Scenario Manager, where changing a single cell on the Summary worksheet changes the visible scenario throughout the rest of the workbook. Data Tables are working a treat providing the headline values for each option.
I'd like to have a drop down on each sheet that when changed will change the same single cell on the Summary worksheet, so I don't need to go back to the Summary sheet every time I want to switch visible scenarios.
This is a simple process if I'm using macros and would be the solution I'd normally jump straight to. But this needs to be done without macros and this is where I'm now struggling.
Does anyone know if this is possible (without macros) and point me in the right direction?
Josh
You can insert combo box (Developer Tab > Insert > Form Controls > Combo Box) on each sheet. Mention linked cell as a cell of the summary sheet (Absolute reference with sheet name). That cell will give you index of the item selected in the drop down list. Then you can insert index formula in the cell you want to change every time to get value of the drop down list. Once you insert it on one sheet you can copy it to other sheets. No macros required.

How to Paste into visible cells in a filter in Excel?

I have data in one workbook and I have filtered columns in another workbook, when I want to copy the data from one workbook and paste it to the visible cells in the filtered area, it gets pasted to the hidden cells as well.
I googled alot but nothing was useful even I tried the Kutools software but did not work.
How to paste the data into visible cells?
A workaround I like to use is to use reference in the filtered sheet. Slightly longer method, but it works. Follow the steps below
Set the reference in first cell. E.g. ='Sheet1!A1'
Click and drag to copy the formula to all cells below (or Copy, and Paste into multiple selection). DO NOT double click to fill down, as it will include hidden cells.
If needed, clear filter and copy- paste values
Let me know if this works for you.

Column header validation with different sheets using macros

In Excel, I have 4 column headers (Id, Name, Age, Place).
I have 3 Excel worksheets with same column headers and different data.
I want to make a consolidated worksheet and the constraint is I have to check whether the column header is the same in all 3 worksheets and move it into the consolidated worksheet.
In the 1st worksheet I have values in the first row.
In 2nd worksheet, the first row is empty and the second row has data.
In 3rd worksheet, the first and second rows are empty and the 3rd row has data.
The 4th worksheet is the consolidated one. I want all 3 worksheet's data in this sheet.
How to do it with macros in vba?
There's built-in functionality for data consolidation.
You'll need to move your data so it's all on the same row but in the end will probably be much easier than writing code from scratch.
How to consolidate
Follow these steps to consolidate several worksheets into a master worksheet:
If you haven't already, set up the data in each constituent sheet by doing the following:
Ensure that each range of data is in list format. Each column must have a label (header) in the first row and contain similar data. There must be no blank rows or columns anywhere in the list.
Put each range on a separate worksheet, but don't enter anything in the master worksheet where you plan to consolidate the data. Excel will do this for you.
Ensure that each range has the same layout.
In the master worksheet, click the upper-left cell of the area where you want the consolidated data to appear.
Note: To avoid overwriting existing data in the master worksheet, ensure that you leave enough cells to the right and below this cell for the consolidated data.
Click Data → Consolidate (in the Data Tools group).
In the Function box, click the summary function that you want Excel to use to consolidate the data. The default function is SUM.
Here is an example in which three worksheet ranges have been chosen:
Select your data.
More information and the remaining instructions are at the source.
If you want to automate the process, record a macro as you performs the necessary steps and then you can edit as required.
See: Recording a Macro to Generate Code as well as Revising Recorded Visual Basic Macros. If you're not familiar with Excel (or whatever you're planning on automating with VBA), do that before attempting VBA.
This VBA tutorial is highly recommended: Excel VBA For Beginners and Microsoft's Documentation.

Formula To Paste Table In Seperate Worksheet In Excel

I have a table located on Sheet1 called Table2, I just need a way to paste it onto Sheet2 in a certain cell to prepare it for a CSV file. Is there a formula I can use in a cell to display my table in a different sheet?
Table2 dynamically changes from week to week, so I need a formula that'll copy and paste the whole table onto Sheet2.
I've only found how to do a structured table reference, but have not found how to copy and paste the whole table.
In VBA you can use this one line of code in a new module:
Sub CopyTable1ToSheet2A1()
Sheet1.ListObjects("Table1").Range.Copy Destination:=Sheet2.Range("A1")
End Sub
tl;dr; You can insert the table from a connection.
Create your source table if not there already.
Change name if you want, mine is src_table:
Goto "Data -> Get External Data -> Existing Connections"
Goto "Tables" tab and select your table:
In the "Import data" dialog, select how as "Table" and where as wherever you want. In my case I put it in my existing Sheet2 cell A4.
Press Ok
Now if you update the original table in Sheet1, then come back to Sheet2, right click and "Refresh", it'll fetch teh latest data.

Excel: Creating a buttong to save current version and reset cells

I currently use a printed out grid to document my work, but its a bit of a pain to search through and organize. I'd like to go digital, but want to find an easy 'Save current Version' and 'Reset form' option.
If that's is unclear, I want to make a button that will save the spreadsheet, exactly as it is at the time of click (using a name I enter in cell A1), then reset the contents of the spreadsheet.
They can be two separate buttons if needed, but that is the minimum requirement.
I have done this before, and with a little planning can be accomplished through a recorded macro.
Steps:
Create 2 Worksheets, "Form" and "Data".
Design the form on the "Form" worksheet, and populate with sample data.
On the top row of the "Data" worksheet, create references to the fields you to record.
Now Go back to the "Form" worksheet. and start the macro recording.
Go to the "Data" worksheet, right click the row header below the reference row created in step 3 and select "Insert".
Right Click on the row header of the reference row created in step 3 and select "Copy".
Right Click on the row header of the newly insert row from step 5 and select "Paste Special > Values".
Go back to the "Form" worksheet and delete all the placeholder values.
Stop the macro recording and save.
Insert a button that points to the newly created macro.
You can also do this all with VBA, but for a simple task like this, the Record Macro function is perfect.

Resources