Implement a function that, upon clicking the "Export" button, creates a new sheet in the workbook and populates it with the article numbers and corresponding quantities from the Data sheet range. The information should be presented in a columnar format without any empty rows.
Develop a feature that generates a new worksheet containing the article numbers and their respective quantities, extracted from the Data sheet range, when the "Export" button is clicked. The data should be organized in a tidy, column-based layout, devoid of any gaps between rows.
Create an Export button that activates a script capable of producing a fresh spreadsheet, filled with the article numbers and corresponding quantities retrieved from the Data sheet field. The data should be arranged in a vertical, column-style format, with no blank rows or other irregularities.
want to copy data on first sheet to another sheet
select cells on columns AB, AC, AE and AF
export selected sells to the new sheet called new Data sheet
list the selected cells and export them
AB and AE refers to articles
AC and AF refers to quantity
Sub exportFunction()
Dim ws As Worksheet
Dim destWS As Worksheet
Dim lastRow As Long
Dim i As Long
Set ws = ActiveSheet
Set destWS = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
destWS.Range("A1").Value = "Article Number"
destWS.Range("B1").Value = "Quantity"
lastRow = ws.Cells(ws.Rows.Count, "AB").End(xlUp).Row
For i = 2 To lastRow
If ws.Range("AB" & i).Value <> "" Then
destWS.Cells(destWS.Rows.Count, "A").End(xlUp).Offset(1, 0).Value = ws.Range("AB" & i).Value
destWS.Cells(destWS.Rows.Count, "B").End(xlUp).Offset(1, 0).Value = ws.Range("AF" & i).Value
End If
Next i
destWS.Columns("A:B").AutoFit
End Sub
Bookmarks