add a value to column E if Column A has a value >0 on the same row VBA - vba

How can I add a Cell Value from another Sheet to a Column E as long as the Cell in Column A is >0. I need it to move down a Row if true and end or 'go to line' if = 0?
Sheet1 has the one Cell needed for the Copy and Paste Value.
Sheet2 has a Table that spans from Column A to Column E.
This will be Looped through many Workbooks and there are an unknown amount of Rows.
I am using Excel. How should I start this VBA. I can't seem to figure out how to drop down a row for both columns.
Any and All suggestions will be appreciated, thanks.

Related

Excel - Have a value from column B of a 2 column reference pasted anytime the value from column A is entered on a separate worksheet

In the example I have a 2 column reference where data in column E is correlated to column F. I need the data in Column F to show up anytime data from Column E is entered in a separate worksheet if possible.
To be clear, is it possible to enter data in Column A of Sheet 1 that pulls the correlated data from column B in reference Sheet 2 and enters it into Column B of Sheet 1?
I tried using a simple function in a single sheet but it obviously doesn't do what I need.
You are after VLOOKUP or INDEX MATCH
Sheet1 b1 and fill down rows
=IFERROR(VLOOKUP(A1,Sheet2!E:F,2,FALSE),TEXT(,))
Or
=IFERROR(INDEX(Sheet2!F:F,MATCH(A1,Sheet2!E:E,0)),TEXT(,))
If you set you data up as tables the formulas will autofill down. Rather than use entire columns you can set to the ranges containing data.
Data:

Trying to Insert blank rows x number of times, x = cell value

I am trying to insert a specific number of blank rows, which is based on a value in a cell. This value in the cell is a count function from a table.
I have an "Import Table" sheet which contains all my data. Next to the table I have a couple count functions, which count general categories coming from the table. For example on the "Import Table" worksheet Cell J8(Domestic Equity), Cell J9 has the count function which for this case comes to "11". I now want 11 rows to be inserted at a specific spot in my "Analysis" worksheet. In this worksheet there are heading also names like the count headings(domestic equity).
So under domestic equity I want the rows to be insert. In the analysis sheet a function is already created in the first row under domestic equity, so the new blank rows have to be inserted under that value in this case under row 6.
The formula already existing in cells (A6,B6,C6,D6,E6) then have to be flash filled into the newly created white rows.
I attached 2 images to hopefully clear up my questions.
Thanks!
Range("A1").Resize(11, 1).Insert (xlShiftDown)
OR
Rows(1).Resize(11, 1).Insert (xlShiftDown)

Excel VBA - selecting the range from first row to the last row

I have a problem with VBA code. I have a sheet with a lot of data around the cells I want. I need to select data in column F, but the position of the first and last cells between the range is to be selected is changing up and down. I created the non empty cells in row X where there is no data do the LastRow function has any refernece but now I dont know how to select the first row
thx for help
If F1 is empty, this selects the first cell with data in the F column
Worksheets("Sheet1").Range("F1").End(xlDown).Select
If F1 may be non-empty you can add a check to see whether it contains text.

How do I copy specific cells from sheet 1 and paste into corresponding rows of sheet 2 , based on values of cells in sheet 2?

I have Sheet 1 with lots of columns, where column A is the list of all customer codes. In sheet 2 I have column A as some selected customer codes. Now based on the selected customer codes in sheet2 I need to extract few columns (H,I,J) from sheet1, paste it into sheet 2 and export the result to a new sheet.
Excel noob here. Hope you understood my query.
Assuming customer codes are unique in column A (i.e., the same code does not appear multiple times) you can do all of this with VLOOKUP function.
No need for VBA. In column B, Sheet 2: =VLOOKUP(A1,Sheet1!A:J,8,False) will return the value corresponding from column H (H being the eighth column of the range A:J).
Likewise do this for column I:
=VLOOKUP(A1,Sheet1!A:J,9,False)
And if you guessed also do this for column J:
=VLOOKUP(A1,Sheet1!A:J,10,False)

VBA code to copy rows from one excel sheet to another

The original spreadsheet was from column A to E. I just pasted the numbers in column F from another sheet. My new spreadsheet has 1517 rows and goes from columns A-H. The numbers in column F (row 2 to row 420) are also in column C.
I was able to use the MATCH function of Excel to find the exact position of a number in column C i.e In column C, on which row can I find the numbers that are in column F? For instance, the number "12345678910" in cell F2 can be found in cell C1049,on row 1049. I put those position numbers in a column that I called "index".
Now, the goal is to write a vba code to copy those rows at once. I am trying to extract/copy to another sheet the numbers in column F that are also in column C but I only want columns A to E - from the original sheet. Copy each row number that is in the index column but only the columns A-E. To be clear, "12345678910" is also in cell C1049. "Copy row 1049 from column A-E" and do that for each position number in the index column.
I cannot sort the spreadsheet because the columns A-E are linked. A sort would alter the information. Any help would be appreciated.
A sample of my spreadsheet
Sub filterCopy()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheet1
Set ws2 = Sheet2
ws1.Range("A1:F1517").AutoFilter 6, "<>"
ws1.Range("A1:F1517").SpecialCells(xlCellTypeVisible).Copy ws2.Range("A1")
End Sub