Transfer from one Excel sheet to another..
Closed
VB rookie
-
Jul 15, 2011 at 08:46 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jul 19, 2011 at 11:37 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jul 19, 2011 at 11:37 AM
Related:
- Transfer from one Excel sheet to another..
- Transfer data from one excel worksheet to another automatically - Guide
- Free fire transfer - Guide
- Excel move data from one sheet to another - Guide
- Excel hyperlink to another sheet - Guide
- Sheet right to left in google sheet - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jul 15, 2011 at 09:14 AM
Jul 15, 2011 at 09:14 AM
So if a row has only 1 column used (column A), then that needs to be copied to the the last row above it that had A-d column populated ? Ok it sound confusing. What I am trying to ask is that, row 1 has 4 columns populated, row 2 has only one, then row 3 has only one and row 4 has 4 columns populated
so row1 remains row 1
row2 gets removed and its value get populated in cell E of row 1
row 3 gets removed and its value get populated in cell F of row 1
row 4 remains same
so row1 remains row 1
row2 gets removed and its value get populated in cell E of row 1
row 3 gets removed and its value get populated in cell F of row 1
row 4 remains same
Jul 15, 2011 at 12:01 PM
Jul 15, 2011 at 12:40 PM
Jul 15, 2011 at 01:41 PM
Jul 18, 2011 at 08:18 AM
https://docs.google.com/leaf?id=0B0YwZcISo6AWMWY5YWNlYmEtMDZhZC00YWE1LThiNGQtMGQzODExYjQ0ZTJk&sort=name&layout=list&num=50
the "071411 ScanSheet" tab contains an example of the inventory data scanned into the system, and the "071411 SortSheet" tab contains an example of how i want the data transferred over for sorting purposes later on.
Jul 19, 2011 at 06:31 AM
Public Sub doUpdateSortSheet() Dim sSrcSheet As String Dim sDesSheet As String Dim lTotalSrcRow As Long Dim lSrcRow As Long Dim lDesRow As Long Dim wsSrc As Worksheet Dim wsDes As Worksheet sSrcSheet = "071411 ScanSheet" sDesSheet = "071411 SortSheet" lTotalSrcRow = getItemLocation("*", Sheets(sSrcSheet).Rows) If (lTotalSrcRow < 2) Then Exit Sub Set wsSrc = Worksheets(sSrcSheet) Set wsDes = Worksheets(sDesSheet) lDesRow = getItemLocation("*", wsDes.Rows) If lDesRow = 0 Then lDesRow = 1 lSrcRow = 2 Do While (lSrcRow <= lTotalSrcRow) If (wsSrc.Cells(lSrcRow, "B") <> vbNullString) _ Then If (wsSrc.Cells(lSrcRow + 1, "B") = vbNullString) _ Then lDesRow = lDesRow + 1 wsSrc.Range(wsSrc.Cells(lSrcRow, "A"), wsSrc.Cells(lSrcRow, "D")).Copy wsDes.Cells(lDesRow, "A").PasteSpecial wsSrc.Cells(lSrcRow + 1, "A").Copy wsDes.Cells(lDesRow, "E").PasteSpecial wsSrc.Cells(lSrcRow + 2, "A").Copy wsDes.Cells(lDesRow, "F").PasteSpecial lSrcRow = lSrcRow + 2 With wsDes.Range(wsDes.Cells(lDesRow, "A"), wsDes.Cells(lDesRow, "F")) .Interior.ColorIndex = xlNone .Font.Bold = False .FormatConditions.Delete End With Else lSrcRow = lSrcRow End If Else lSrcRow = lSrcRow End If lSrcRow = lSrcRow + 1 Loop Set wsSrc = Nothing Set wsDes = Nothing End Sub Public Function getItemLocation(sLookFor As String, _ rngSearch As Range, _ Optional bFullString As Boolean = True, _ Optional bLastOccurance As Boolean = True, _ Optional bFindRow As Boolean = True) As Long 'find the first/last row/column within a range for a specific string Dim Cell As Range Dim iLookAt As Integer Dim iSearchDir As Integer Dim iSearchOdr As Integer If (bFullString) _ Then iLookAt = xlWhole Else iLookAt = xlPart End If If (bLastOccurance) _ Then iSearchDir = xlPrevious Else iSearchDir = xlNext End If If Not (bFindRow) _ Then iSearchOdr = xlByColumns Else iSearchOdr = xlByRows End If With rngSearch If (bLastOccurance) _ Then Set Cell = .Find(sLookFor, .Cells(1, 1), xlValues, iLookAt, iSearchOdr, iSearchDir) Else Set Cell = .Find(sLookFor, .Cells(.Rows.Count, .Columns.Count), xlValues, iLookAt, iSearchOdr, iSearchDir) End If End With If Cell Is Nothing Then getItemLocation = 0 ElseIf Not (bFindRow) _ Then getItemLocation = Cell.Column Else getItemLocation = Cell.Row End If Set Cell = Nothing End Function