Consulting

Results 1 to 8 of 8

Thread: Code for selecting data and paste in another tab

  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location

    Code for selecting data and paste in another tab

    Hi,

    I am looking for a code which select data from data tab and paste in Final tab as per creteria mention in Selection tab.


    Sheet attached

    Thank you
    Attached Files Attached Files

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    Here is a variation of your project. Will this work ?

    Option Explicit
    Sub CopyInfo()
    Dim wkSht As Worksheet
    Dim cell As Range
    Dim nextRow As Long
    Dim lRow As Long
    Dim i As Integer
    Dim celltxt As String
    Dim celltxtval As String
    Dim cellyearval As String
    
    
    Application.ScreenUpdating = False
    
    
    lRow = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
    For Each wkSht In Sheets
        Sheets("Data").Activate
        For i = 2 To lRow
            
            If Sheets("Data").Range("A" & i).Value = wkSht.Name Then
                Sheets("Data").Activate
                nextRow = wkSht.Range("A" & Rows.Count).End(xlUp).Row + 1
                Sheets("Data").Range("A" & i).EntireRow.Copy Destination:=wkSht.Range("A" & nextRow)
           End If
           
        Next i
    Next wkSht
    
    
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

  3. #3
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location
    That is good and working fine but I have different requirement...I want one name to be added in another one.....Like if we select FGT data, then its data should be added in HYT and then make FGT data zero after adding to HYT...so may be that can be done just by applying simple sum formula...so what exactly needed is FGT data should pasted in Final sheet in A2 cell onwards and HYT data in A8 cell onwards....then A16 onwards we have sum formula..then this A16 data should replace data of HYT and make FGT data zero...and last thing we don't want to select every row in FGT..only row for Mkt and Fin in Dept. I am also working on this...will update if I get something

  4. #4
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location
    Adding another attachment
    Attached Files Attached Files

  5. #5
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    I apologize. I am totally confused now.

  6. #6
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location
    Sorry for the confusion,,,let me try to explain it agian.
    ok what is needed is...code will select name as per selection tab..so now we want 2 names in final sheet.
    First data from data sheet will pated in first table lets say data for FGT or Fin & Mkt dept only...second name data from data sheet will pasted in 2nd table in final sheet lets say for HYT again for Fin & Mkt dept only (i have highlighted them in Attahed new sheet)
    3rdtable in fnal sheet is sum of FGT and HYT
    Now last thing we want....FGT data should be zero in data sheet for Fin & Mkt dept and for HYT new sum data of 3rd table will replace it.

    I hope this time itmake sense..thanks

  7. #7
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location
    Attached new sheet
    Attached Files Attached Files

  8. #8
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location
    Until now i am come up with this.....it is pasting whole data as per their respective names in selection data to final sheet.

    But i need only 2 dept names data Fin & Mkt and then 3rd table data of final sheet will replace HYT data in data sheet.

    and make all FGT data zero in Data sheet for FIin Mkt dept.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •