first post here and relative newbie to everything VBA!
Ideally, what I am looking for is a macro that will take a value entered into a cell, VLOOKUP against an array on another sheet and paste the value in the next blank cell in that row, with a date/time stamp in the next blank adjacent cell. I'd like to be able to keep the original data so that if the macro runs again it doesn't overwrite any previously pasted data.
For example, the data to copy/paste will be entered into cell D2 on sheet 2, the value to lookup is in B2 on sheet 2. The array to look against is Sheet 6 Column A with columns B and C for the pasted value and date/time stamp respectively.
Any help is greatly appreciated!
Ant.
Related
I am trying to copy and paste A8:P8 in to the Blank Rows (as per pic below) until the data in column Q is blank - is there a VBA which can do this? I need to do this on multiple tabs so the row number will be variable.
Although you could accomplish this with VBA, have you tried just using cell formulae?
For example, in the first empty cell in column A you'd put:
=$A$8
then the same for each other cell in the row, changing the column letter.
Then select all of the cells with formula and double-clicking the autofill handle which will copy the formula down to the last row with data in the adjacent column.
I have been trying to get the above data which is presented datewise in Column form to be pasted in the below format in Row form, but challenge is either 1 date at a time can be taken or either single cell reference needs to be given in each cell on other sheet, need some shortcut such that sheets data remains dynamic and datewise data is copied. Image shows it in one sheet, above data is required to be shown in below format in other sheet.
Thanks and Regards
Mandeep Goraya
For example, your table is like this:
Put this code into cell B8 then fill right:
=INDEX($B$2:$F$3,MOD(COLUMN(A1)-1+ROWS($B$2:$F$3),ROWS($B$2:$F$3))+1,1+INT((COLUMN(A1)-1)/ROWS($B$2:$F$3)))
I have written 2 Excel functions to copy data to cell G12 when data is entered in cell F12
=IF(ISBLANK(F12)," ",(F12))
if data in the deleted from cell G12 it is copied to H12
=IF(ISBLANK(G12),(F12)," ")
these work perfectly but I was wondering if the same procedure can be carried out in vba on a dynamic range as I want to keep adding rows
To achieve your requirements, you can format your range as a table from Home>Format as Table. Now, assuming your table as two columns respectively named "name" and "non blank name", you can enter the following formula in the second cell of the second column:
=IF(ISBLANK([#Name])," ",[#Name])
As you add rows to the table, the formula will be copied automatically to the new row.
I know the title is really long winded, I will try to explain
I am trying to get Magento products into Zen Cart (background only - shouldn't be relevant).
I have an excel 2010 xls spreadsheet and in it I have a load of product data: skus, prices, categories, etc... you get the idea. I have each of the products along with their data listed once, each with a unique SKU field.
But... Some of these products are in more than one category and the way I am importing, each product needs to be listed multiple times, once for each category.
So, I have done an sql dump which contains two columns; sku and category. I have pasted these values into excel as new rows, so now I have a situation like this (with a lot more entries):
As you can see for each sku (left highlight) there is one entry containing all the data apart from the category (right highlight) and then there is an additional entry for each category it belongs to which contains only the category and sku but none of the other data.
So, what I need to do is some how copy all the data (apart from the categories column) across all cells with the same sku. Does anyone have any idea how I can achieve this without hitting Ctrl+V several hundred times. I realise VBA can probably handle this pretty easily, but I dont have a clue on that front.
Any help greatly appreciated
I hope you’re willing to use a second sheet, and to reference the data rather than actually copying.
On Sheet2, set A1 to =IF(Sheet1!A1="", "", Sheet1!A1). Drag (extend/fill) this down to A500 (as much data as you have on Sheet1, or further, to allow for growth). Also drag A1 over to AA1 and then drag that down to AA500.
Then set B2 to =IF($AA2="", Sheet1!B2, B1), drag it to Z2, and drag B2:Z2 down to B500:Z500.
P.S. If any of your data (columns) are dates, you will probably need to explicitly format them as dates on Sheet2. Ditto for any other values that are formatted any non-default way (e.g., Currency or Percentage). It may be necessary to do this only to cells that have values in them (and not blank cells).
You don't need VBA, unless you need to do this many times.
Assuming the sheet with your data is called Source and the sheet with the result is called Dest, you can get what you want following these steps on the sheet Dest:
On A1 type =Source!A1
On A2 type =IF(ISBLANK(Source!A2),A1,Source!A2)
Select the range A1:XX1 (where XX is the last column of the sheet Source)
Press Ctrl+R (to copy the first cell to the right)
Select the range A2:XX## (where ## is the last row of the sheet Source)
Press Ctrl+R and Ctrl+D (to copy to the right and down)
Here is an explanation of what's going on:
The first row is copied from the Source as it is.
Each cell of the second row is copied from Source only if that cell is empty, otherwise the cell above is copied.
Here's the quick and dirty solution:
Select the columns you need to be filled
Press Goto Ctrl-G
Special `Alt-S'
Blanks (Alt-K, Enter)
This should select all blank cells. Now type =B2 (assuming you're in B3, i.e. use the cell above the active cell) Important: Press Ctrl-Enter instead of Enter to enter the formula.
Done!
On a new Worksheet get the numbers 1-26 running across the top in Row1 by typing 1 in cell A1, 2 in cell A2, and then selecting those two cells and filling through Z.
Now in A2 type the following formula =VLOOKUP(Sheet1!$A1,Sheet1!$A:$AA,VALUE(A$1),FALSE)
Fill this formula in the Range A2:Z## (where ## represents your last row of data).
Then copy Row1 from Sheet1 to Row1 on Sheet2.
This formula will copy the rows of data straight down into the empty rows below them (assuming the sku only changes where there is a row of new information.
This will then all be active formulas, so I would recommend selecting all on Sheet2 and right-clicking in cell A1, and paste special by value.
I have Two Excel sheets. My requirement is when I select a reason value from one Excel sheet Reason_Name column, it will display that reason value in a second Excel sheet.
So using Macro, I want to display the second Excel rows on selection of reason in first Excel.
Please Help.
This is the first Excel sheet - Reason_Name column contains Reason1, Reason2, etc.
alt text http://www.freeimagehosting.net/uploads/a10d6be7a5.png
This is the second Excel sheet
alt text http://www.freeimagehosting.net/uploads/99e0ff4cdb.png
Here's something that may get you started. (I think this is close to what you would like to do.)
Create a named range for the data on the second sheet. Named "new_range" in my example.
Then create the following procedure in a new module:
Sub FilterSheetTwo()
Worksheets("Sheet2").Range("new_range").AutoFilter Field:=6, Criteria1:="Reason1"
End Sub
When you run this procedure, it should filter the results on Sheet2.
You can then hook this procedure up to an Worksheet_Change event on Sheet1.
If you can sort your Reason column on the second sheet and place it as the left-most column you don't need a macro--you can do this using VLOOKUP. Steps:
Sort Data by your Reason column on the second sheet.
In each column of the first sheet enter the following formula:
=VLOOKUP(E2, DataRangeOfSheet2, ColumnYouWantFromDataRange)
See VLOOKUP for more info.