![]() |
#1
|
|||
|
|||
![]()
Hello all! So, I have always used Excel but have only gone deeper into formula and VBA writing when my new job required me to do it. Thus, any help is very much appreciated.
![]() I have an Excel workbook that contains a list of items in multiple worksheets. What I'd like it to do is transfer all rows containing values in each worksheets into a new, compiled worksheet, ready to be exported as a CSV. Here is the macro I have cut and pasted for one of those worksheets so far: Code:
Sub SkipBlankRowsSITEWORKS() Dim sourcesheet As Worksheet Dim finalrow As Long Dim i As Long Dim j As Long Set sourcesheet = Worksheets("SITEWORKS") 'change the sheet name accordingly With sourcesheet finalrow = .Cells(.Rows.Count, 3).End(xlUp).Row End With j = 2 'starting row for the active sheet For i = 6 To finalrow If sourcesheet.Cells(i, 4) <> "" Then 'Target cell to see if empty or not ActiveSheet.Cells(j, 1).Value = sourcesheet.Cells(i, 1).Value & " " & sourcesheet.Cells(i, 2).Value ActiveSheet.Cells(j, 2).Value = sourcesheet.Cells(i, 2).Value ActiveSheet.Cells(j, 3).Value = sourcesheet.Cells(i, 3).Value ActiveSheet.Cells(j, 4).Value = sourcesheet.Cells(i, 4).Value ActiveSheet.Cells(j, 5).Value = sourcesheet.Cells(i, 5).Value ActiveSheet.Cells(j, 6).Value = sourcesheet.Cells(i, 6).Value ActiveSheet.Cells(j, 7).Value = sourcesheet.Cells(i, 7).Value j = j + 1 End If Next i End Sub Code:
Sub SkipBlankRowsPRELIMS() Dim sourcesheet As Worksheet Dim finalrow As Long Dim i As Long Dim j As Long Set sourcesheet = Worksheets("PRELIMS") 'Assign worksheet as data source With ActiveSheet Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select End With With sourcesheet finalrow = .Cells(.Rows.Count, 3).End(xlUp).Row End With For j = 2 To finalrow If ActiveSheet.Cells(j, 1) <> "" Then ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select End If Next j 'starting row for the active sheet For i = 6 To finalrow If sourcesheet.Cells(i, 4) <> "" Then 'Target cell to see if empty or not ActiveSheet.Cells(j, 1).Value = sourcesheet.Cells(i, 1).Value & " " & sourcesheet.Cells(i, 2).Value 'Concatenation of Cost Code & Title ActiveSheet.Cells(j, 2).Value = sourcesheet.Cells(i, 2).Value ActiveSheet.Cells(j, 3).Value = sourcesheet.Cells(i, 3).Value ActiveSheet.Cells(j, 4).Value = sourcesheet.Cells(i, 4).Value ActiveSheet.Cells(j, 5).Value = sourcesheet.Cells(i, 5).Value ActiveSheet.Cells(j, 6).Value = sourcesheet.Cells(i, 6).Value ActiveSheet.Cells(j, 7).Value = sourcesheet.Cells(i, 7).Value j = j + 1 End If Next i End Sub I figured this is the first hurdle to be resolved first before looking into how to get the macro to run through each worksheet as mentioned earlier on. Thank you in advance everyone! |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Transfer data from list with multiple headings from word to excel | psohms | Word | 1 | 06-11-2015 04:39 PM |
![]() |
spc94 | Word VBA | 1 | 06-03-2015 09:56 PM |
Transfer Data between Excel and Word | s_samira_21 | Excel | 0 | 01-19-2015 05:21 AM |
Data transfer from Word tables to Excel | shoro | Word | 4 | 10-01-2013 05:08 AM |
![]() |
markhuges | Publisher | 8 | 10-23-2011 05:55 AM |