• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

HELP: Automatically transfer data from one sheet to another

MARGOT347

New Member
Hello everyone!

I have a workbook with 2 worksheets.I need to populate Sheet 1 with the data from Sheet 2. I tried to use only the formula like If or Vlookup but it's not working. I guess I have to use VBA but I am not very good at it. Also is the Value is 0 or if there is no value the row as to be delete.
I guess I have to use:
sub sup()If cells(D3)= 0 then rows(3).delete
end sub
but i am not sure
I attached an example of the type of excel document I have to work on. Could you explain me, how I should proceed please?

Knowing that in my excel file I have about 1000 row of meter data.
Many Thanks!!
thumb.gif


ps: Sorry if my english is not perfect.
 

Attachments

  • Tableau meter.xlsx
    142.8 KB · Views: 3
Margot

Firstly, Welcome to the Chandoo.org Forums

Can you please explain what you require?

On Sheet1, do you want a list of all Meter ID's or do you want to select which ones to query?

For the Dates, Do you want to enter them in or extract the earliest and latest dates?

The Reading value I assume you want the sum of values between the dates?

Please elaborate above
 
Thanks for your answer but I just find out how to do it! I guess I have to use VBA

Code:
OptionExplicit

Sub Test()

Dim WsS As Worksheet, WsC As Worksheet

Dim DerLigS As Long, LigneS As Long, LigneC As Long

Dim DerColS As Integer, ColS As Integer

  Set WsS = Worksheets("Sheet2") 'Feuiller source

  Set WsC = Worksheets("Sheet1") 'Feuille cible

  DerLigS = WsS.Range("A" & Rows.Count).End(xlUp).Row

  DerColS = WsS.Cells(3, Columns.Count).End(xlToLeft).Column

  LigneC = 3

  Application.ScreenUpdating = False

  WsC.Range("A3").CurrentRegion.Offset(2).ClearContents

  For LigneS = 4 To DerLigS

  For ColS = 2 To DerColS

  If WsS.Cells(LigneS, ColS) > 0 Then

  WsC.Cells(LigneC, 1) = WsS.Cells(LigneS, 1).Value

  WsC.Cells(LigneC, 2) = WsS.Cells(3, ColS).Value

  WsC.Cells(LigneC, 3) = WsS.Cells(3, ColS + 1).Value

  WsC.Cells(LigneC, 4) = WsS.Cells(LigneS, ColS).Value

  LigneC = LigneC + 1

  EndIf

  Next ColS

  Next LigneS

  Application.ScreenUpdating = True

  Set WsC = Nothing: Set WsS = Nothing

End Sub
 
Last edited by a moderator:
Back
Top