Excel VBA - Import or copy columns to another workbook in a different order - vb.net

I am trying to import an excel file having headers as A1, B1, C1, D1, A2, B2, C2, D2, A3, B3, ...D4 and each of the headers having data for 150 rows. I have to import this data set to another workbook but in the order:
A1, A2, A3, A4, B1, B2, B3, B4,....D4

You can do it by doing a custom sort.
Home Tab >> Sort & Filter >> Custom Sort >> Options
Then change the sort from "Sort top to bottom" to "Sort left to right". Then its just a matter of selecting which row and how you want to sort it.

Related

How to fill empty cells with values from upper non empty cell in libreoffice calc without using macro/coding

I want to fill empty cells with value from upper non-empty cells, ms excel have ctrl+d for doing that. but i want one step further I want to do multi hop ctrl+d.
For Example
A1, A3, A9, A25, A28 have some value and all other cells of column A are empty I want to fill cell A2 with value of A1,cells A4 to A8 with value of A3,cells A10 to A25 with value A9,cells A26 to A27 with value of A25
Other columns also have such empty cells and I want to fill them like I want for column A.
Folowing are images of sample excel:
I can fill the empty cells by grading cell down for each hop.
For given example I can fill cells by dragging down A1, A3, A9, A25, A28 each.
But I want to do that in one go because I have this type of empty cells and filled cells in between empty cell in thousands.
how can I do that?
Assuming the 1st table content is in A1:C15, put :
=IF(A2="",E1,A2) in E2
=IF(B2="",F1,B2) in F1
=IF(C2="",G1,C2) in G1
and drag downwards..
Hope it solves..
You might like this trick
Just use simple formula and Ctrl+Shift+V (Paste Special - Skip Empty Cells)

how to copy values in a diagonal down a range using vba

I have a range of data in one column like so:
and I'm trying to copy each value after the one in "A1" and move it one column over and up one row, for example (A2 copied to B1, A3 copied to B2, A4 copied to B3 etc.) like so:
Is there a few lines of code that can do this successfully?
In B1:
=IF(ISBLANK(OFFSET($A1,COLUMN()-1,0)),"",OFFSET($A1,COLUMN()-1,0))
fill down and across
Alternate:
=IF(ROW(B1)>COUNTA($A:$A)-COLUMN(A1),"",INDEX($A:$A,COLUMN(B1)+ROW(B1)-1))

For Excel VBA, If B2 value did not change then A2 will keep same, If B2 is changed then A2 will increase by one

I need a VBA for the whole column B and A says that
if Value of Cell B2 did not change then A2 value will be the same
if B2 value is changed then A2 value will increase by one
Use this formula.
Put your staring number in A1.
Put this in A2:
=IF(B2<>B1,A1+1,A1)
And copy down.

Call a cell by using a value in another cell

I am trying to call a simple cell (Eg: =a1) in Excel. However this "a1" is available in another cell, let's say in cell 'e1'.
In another way, what I mean is e1 cell has the value "a1" in it and for that reason alone I want to call a1. Finally will in turn populate the value that is actually in a1.
I need to do this is because the cell no. that needs to be populated is retrieved from a formula in e1. That is how the cell a1 comes into the picture.
Using the function: =Indirect([cell]) will give you the value in the [cell]. For example, if cell Z1 has the function =Indirect(E1), and E1 has the value A1, will give you the value of A1 in Z1. Then if E1 changes to, say, A2, then cell Z1 will contain the value from A2.

VBA Resize Array, 1 Column to 4 Columns

So I copied some data into Excel, but unfortunately for me when I pasted the data the chart format sorta died, so I ended up with a 1 column full of data(Column A). Basically A1 is suppose to be Movie name, A2 is suppose to be in B1(Cost of movie), A3 is suppose to be in C1(How long is the movie), and A4 is suppose to be in D1(Sequel:yes/no). And A5 is suppose to be in A2, A6 in B2, A7 in C2, A8 in D2, A9 in A3, A10 in B3..etc.. Its suppose to be a chart with 4 columns, but everything ended up in column A. Anyone can help me write a VBA code to rewrite the first column back to 4 columns? Thanks in advance.
No need for VBA. In excel, use INDIRECT in the four columns
=indirect("A"&(row()-1)*4+1) | =indirect("A"&(row()-1)*4+2) | ...
=indirect("A"&(row()-1)*4+1) | =indirect("A"&(row()-1)*4+2) | ...
...