Hi all,
Im trying to figure out how to loop through a who workbook and copy value if for example B5 value match Sheet name in the other workbook, then i should copy value from E5 to that sheet and place it under the right column so if its for August month it gets the data from then it should paste it just under August(A3) in the other workbook, for Example August is in cell E6 the data should be placed in E7.. And if its the Sales the sale should copied aswell.
Im trying to figure this out but since i dont have enought knowledge im hitting the head in the wall all the time..
This is where the data sheet looks like, and each month have an own sheet (Aug-16) and so on.
And data should be copied to another workbook that looks like this.
So basicly im getting stucked kinda fast have tried too google and find hints on how to do it but not been successful so far.
Tried to make a macro on my own, and this is how far i came.
Yeah i know its now even close... but am im on the right way with the first part of the code..
The sheet may contain sometimes more and sometimes less names under B4 (Agents) it depends on month... So some kind of error handling might be needed? Dont know realy.
Anyone have any clue how this could be done.. As u notice im not that well oriented on this thingie..
Gladly take any help i can get.
Best regards
Daniel
Im trying to figure out how to loop through a who workbook and copy value if for example B5 value match Sheet name in the other workbook, then i should copy value from E5 to that sheet and place it under the right column so if its for August month it gets the data from then it should paste it just under August(A3) in the other workbook, for Example August is in cell E6 the data should be placed in E7.. And if its the Sales the sale should copied aswell.
Im trying to figure this out but since i dont have enought knowledge im hitting the head in the wall all the time..
This is where the data sheet looks like, and each month have an own sheet (Aug-16) and so on.
And data should be copied to another workbook that looks like this.
So basicly im getting stucked kinda fast have tried too google and find hints on how to do it but not been successful so far.
Tried to make a macro on my own, and this is how far i came.
Code:
[FONT=arial]Sub test()[/FONT]
[FONT=arial]
[/FONT]
[FONT=arial]Dim rng As Range[/FONT]
[FONT=arial]Dim row As Range[/FONT]
[FONT=arial]Dim cell As Range[/FONT]
[FONT=arial]Dim WB1 As Workbook[/FONT]
[FONT=arial]Dim wb2 As Workbook[/FONT]
[FONT=arial]Dim ws As Worksheet[/FONT]
[FONT=arial]Dim Ws2 As Worksheet[/FONT]
[FONT=arial]
[/FONT]
[FONT=arial] Set WB1 = ThisWorkbook[/FONT]
[FONT=arial] Set wb2 = Workbooks.Open("F:\Excel\Chef\<wbr>NPS Samtal 777 agentnivå.xlsx")[/FONT]
[FONT=arial]rng = Range("CB:B40")[/FONT]
[FONT=arial]
[/FONT]
[FONT=arial]For Each ws In wb2[/FONT]
[FONT=arial]For Each row In rng.Rows[/FONT]
[FONT=arial] For Each cell In row.Cells[/FONT]
[FONT=arial] If cell.Value = "" Then[/FONT]
[FONT=arial] If rng.Value = WB1.ws Then[/FONT]
[FONT=arial] MsgBox "hi"[/FONT]
[FONT=arial] Else[/FONT]
[FONT=arial] End If[/FONT]
[FONT=arial] End If[/FONT]
[FONT=arial] Next cell[/FONT]
[FONT=arial]Next row[/FONT]
[FONT=arial]Next[/FONT]
[FONT=arial]
[/FONT]
[FONT=arial]End Sub[/FONT]
The sheet may contain sometimes more and sometimes less names under B4 (Agents) it depends on month... So some kind of error handling might be needed? Dont know realy.
Anyone have any clue how this could be done.. As u notice im not that well oriented on this thingie..
Gladly take any help i can get.
Best regards
Daniel