Hi!
I'm having some trouble converting raw-data to a format I can put to use in a pivotable.
At my work we pull data a couple of times a day from a external program, the formatting of that data makes for allot of manual labour before we can present it.
I'm trying to write a VBA scripts that cycles through column A of the data and replace all instaces of "agent total" with the name of the agent.
The name of the agent is always one cell above the active cell.
The only way I have worked with macros before is with the "record macro" function so i'm basically new to this.
I'm using Excel2013
and Windows Xp
I have tried to modify a search an replace recorded macro by editing the replacement value with all kinds of things but nothing remotely works.
I tried yo use a ActiveCell.Offset(-1, 0) to get the content of the cell above
This is how far I come:
The actual data look something like this:
[TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl65, width: 64"]Agent[/TD]
[TD="class: xl66, width: 64"]AgentID[/TD]
[TD="class: xl66, width: 64"]Queue[/TD]
[TD="class: xl66, width: 64"]Calls Inbound[/TD]
[TD="class: xl66, width: 64"]Abandons[/TD]
[TD="class: xl66, width: 64"]AHT IB[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Christoffer[/TD]
[TD="class: xl68, width: 64, align: right"]114110[/TD]
[TD="class: xl68, width: 64"]OSD_Q_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]46[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:12:41[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Christoffer[/TD]
[TD="class: xl68, width: 64, align: right"]114110[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]9[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:23:17[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]159[/TD]
[TD="class: xl71, width: 64"]1[/TD]
[TD="class: xl72, width: 64"]00:13:15[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Henrik[/TD]
[TD="class: xl68, width: 64, align: right"]130080[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Sales_Teknik[/TD]
[TD="class: xl69, width: 64"]3[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:08:40[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Henrik[/TD]
[TD="class: xl68, width: 64, align: right"]130080[/TD]
[TD="class: xl68, width: 64"]OSD_Q_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:00:00[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]68[/TD]
[TD="class: xl71, width: 64"]1[/TD]
[TD="class: xl72, width: 64"]00:11:39[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Johan[/TD]
[TD="class: xl68, width: 64, align: right"]120017[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Teknik[/TD]
[TD="class: xl69, width: 64"]15[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:07:54[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Johan[/TD]
[TD="class: xl68, width: 64, align: right"]120017[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Sales_Teknik[/TD]
[TD="class: xl69, width: 64"]3[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:24:38[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]104[/TD]
[TD="class: xl71, width: 64"]0[/TD]
[TD="class: xl72, width: 64"]00:10:15[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Simon[/TD]
[TD="class: xl68, width: 64, align: right"]130561[/TD]
[TD="class: xl68, width: 64"]OSD_Q_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]90[/TD]
[TD="class: xl69, width: 64"]1[/TD]
[TD="class: xl70, width: 64"]00:09:22[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Simon[/TD]
[TD="class: xl68, width: 64, align: right"]130561[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]26[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:14:10[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]299[/TD]
[TD="class: xl71, width: 64"]1[/TD]
[TD="class: xl72, width: 64"]00:09:15[/TD]
[/TR]
</tbody>[/TABLE]
I know I must be making some basic mistake but I have no idea where to start correcting.
If anyone of you know how to make this work It would be very appreciated.
//Niklas
I'm having some trouble converting raw-data to a format I can put to use in a pivotable.
At my work we pull data a couple of times a day from a external program, the formatting of that data makes for allot of manual labour before we can present it.
I'm trying to write a VBA scripts that cycles through column A of the data and replace all instaces of "agent total" with the name of the agent.
The name of the agent is always one cell above the active cell.
The only way I have worked with macros before is with the "record macro" function so i'm basically new to this.
I'm using Excel2013
and Windows Xp
I have tried to modify a search an replace recorded macro by editing the replacement value with all kinds of things but nothing remotely works.
I tried yo use a ActiveCell.Offset(-1, 0) to get the content of the cell above
This is how far I come:
Code:
Columns("A:A").Select
Selection.Replace What:="agent total", Replacement:= ActiveCell.Offset(-1, 0), LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
The actual data look something like this:
[TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl65, width: 64"]Agent[/TD]
[TD="class: xl66, width: 64"]AgentID[/TD]
[TD="class: xl66, width: 64"]Queue[/TD]
[TD="class: xl66, width: 64"]Calls Inbound[/TD]
[TD="class: xl66, width: 64"]Abandons[/TD]
[TD="class: xl66, width: 64"]AHT IB[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Christoffer[/TD]
[TD="class: xl68, width: 64, align: right"]114110[/TD]
[TD="class: xl68, width: 64"]OSD_Q_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]46[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:12:41[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Christoffer[/TD]
[TD="class: xl68, width: 64, align: right"]114110[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]9[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:23:17[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]159[/TD]
[TD="class: xl71, width: 64"]1[/TD]
[TD="class: xl72, width: 64"]00:13:15[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Henrik[/TD]
[TD="class: xl68, width: 64, align: right"]130080[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Sales_Teknik[/TD]
[TD="class: xl69, width: 64"]3[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:08:40[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Henrik[/TD]
[TD="class: xl68, width: 64, align: right"]130080[/TD]
[TD="class: xl68, width: 64"]OSD_Q_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:00:00[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]68[/TD]
[TD="class: xl71, width: 64"]1[/TD]
[TD="class: xl72, width: 64"]00:11:39[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Johan[/TD]
[TD="class: xl68, width: 64, align: right"]120017[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Teknik[/TD]
[TD="class: xl69, width: 64"]15[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:07:54[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Johan[/TD]
[TD="class: xl68, width: 64, align: right"]120017[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Sales_Teknik[/TD]
[TD="class: xl69, width: 64"]3[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:24:38[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]104[/TD]
[TD="class: xl71, width: 64"]0[/TD]
[TD="class: xl72, width: 64"]00:10:15[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Simon[/TD]
[TD="class: xl68, width: 64, align: right"]130561[/TD]
[TD="class: xl68, width: 64"]OSD_Q_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]90[/TD]
[TD="class: xl69, width: 64"]1[/TD]
[TD="class: xl70, width: 64"]00:09:22[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]Andersson Simon[/TD]
[TD="class: xl68, width: 64, align: right"]130561[/TD]
[TD="class: xl68, width: 64"]OSD_TA_Viasat_Teknik_IPTV[/TD]
[TD="class: xl69, width: 64"]26[/TD]
[TD="class: xl69, width: 64"]0[/TD]
[TD="class: xl70, width: 64"]00:14:10[/TD]
[/TR]
[TR]
[TD="class: xl73, width: 192, colspan: 3"]agent total[/TD]
[TD="class: xl71, width: 64"]299[/TD]
[TD="class: xl71, width: 64"]1[/TD]
[TD="class: xl72, width: 64"]00:09:15[/TD]
[/TR]
</tbody>[/TABLE]
I know I must be making some basic mistake but I have no idea where to start correcting.
If anyone of you know how to make this work It would be very appreciated.
//Niklas