I have values in Sheet1 and sheet2 in columns A, B , C , D and E. Also,these values are some vlookup values from other sheets. Now how should I write code to copy these values(only) from sheet1 and sheet2 and paste in Upload sheet.
NOTE: column Value in Sheet1 and sheet2,
- ** A** to be copied in D of Upload,
- B to be copied in F column of Upload,
- C to be copied in C column of Upload,
- D to be copied in E of Upload
And everytime the number of coulmns to be copied will be different. So when sheet1 is copied to Upload, it has to find the next avaliable row and start coping valus from sheet2 into it.
Private Sub CommandButton1_Click() Dim firstrowDB1 As Long, lastrow1 As
Long Dim lastcol As Long, firstrowDB As Long Dim arr1, arr2, i,
firstRowCount As Integer firstrowDB1 = 1
arr1 = Array("A", "B", "C", "D")
arr2 = Array("D", "F", "C", "E")
For i = LBound(arr1) To UBound(arr1)
Sheets("Sheet1").Columns(arr1(i)).Copy
Sheets("upload").Columns(arr2(i)).PasteSpecial xlPasteValues
Next
Application.CutCopyMode = False
The above code works good for copying sheet1 to Upload in the specific columns but I don't how should I finext next blank cell in Upload sheet and start copying and pasting the values from Sheet 2.
Help Needed please!