Home Extract and sort data from a workbook to another with VBA
Reply: 2

Extract and sort data from a workbook to another with VBA

Alexandru
1#
Alexandru Published in 2017-12-07 16:35:03Z

So my question is simple "How to extract and sort data from a workbook to another"?

I have a document ( let's name it "devices" ) sent over the network, as a result of an another document ( "devices used" ), which sorts some devices used by people in that day. it doesn't arrange the data.

What I wanna do is take that data from that document, and sort it as a table in another workbook.

I know I have to declare the workbook and the sheets, but how to extract and sort the data it's out of my power of knowledge ( yes, I'm new to vba ).

Regards, Alex

Alex Goaga
2#
Alex Goaga Reply to 2017-12-07 17:37:05Z

i think you should start by declaring the Sub Procedures. The first thing there according to your problem should be to declare each workbook required for your task.

The second thing you should do is to declare a for loop statement that would check if of your criteria and if it matches your request, move it by simple using Range statements.

Hope this helps, Alex

Alexandru
3#
Alexandru Reply to 2017-12-07 18:41:21Z

This is my code until now. but my problem is that I don;t know how to copy all data according to the data from my IF.

Sub timp_sortare_deviceuri()

Dim HPS13 As Workbook Set HPS13 = ActiveWorkbook

Dim sheet_date As Worksheet Set sheet_date = Sheets("Sheet1")

Dim HPS1 As Workbook

Dim ultimul_rand_detectat As Integer

Application.Workbooks.Open ("C:\Users\Piulitsa\Desktop\HPS1.xlsx")

Set HPS1 = ActiveWorkbook

ultimul_rand_detectat = HPS1.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

'Debug.Print ultimul_rand_detectat

For rand = 1 To ultimul_rand_detectat

urmatorul_rand = HPS13.Sheets("Sheet1").Cells(Rows.Count, 11).End(xlUp).Row + 1

If HPS1.Sheets("Sheet1").Range("A" & rand).Value = "Data Document:" Then

HPS13.Sheets("Sheet1").Range("K" & urmatorul_rand).Value = HPS1.Sheets("Sheet1").Range("B" & rand).Value

End If

Next rand

End Sub

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.3264 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO