PC Review


Reply
Thread Tools Rate Thread

Complicated Macro - Someone please help.....this will definetly be a challenge!!

 
 
Stuart
Guest
Posts: n/a
 
      1st Nov 2006
I have data in excel. I have a combine macro to combine a hundred
spreadsheets in excel.

This works no problem however...............

The data at the moment in excel looks like,



Name SW
Report : 6



Item Price in Currency Description
Amount1 Amount2
101101 GBP Fridge 1000.00 1000.00
170101 GBP Washing Machine 200.00 200.00
201001 GBP Fund Transfer In 300.00 300.00

201002 GBP 100.00 100.00
201151 GBP 100.00 100.00
211111 GBP 200.00 200.00
311501 GBP 200.00 200.00
402001 GBP 200.00 200.00

Name JB
19/09/2005 00:00 Currency GBP Pound Sterling Report :
6 7.00



Item Price in Currency Description
Amount1 Amount2
101101 GBP Fridge 1000.00 1000.00
170101 GBP Washing Machine 200.00 200.00
201001 GBP Fund Transfer In 300.00 300.00

201002 GBP 100.00 100.00
201151 GBP 100.00 100.00
211111 GBP 200.00 200.00
311501 GBP 200.00 200.00
402001 GBP 200.00 200.00


What I need from a macro is that everytime it finds the word "Name" in
column B it will pick up the cell to the right of that and then paste
it down the account numbers until it sees the word item and then does
the same again.

The expected output from the macro working would be :

Name SW
Report : 6



Item Price in Currency Description
Amount1 Amount2
SW101101 GBP Fridge 1000.00 1000.00
SW170101 GBP Washing Machine 200.00 200.00
SW201001 GBP Fund Transfer In 300.00 300.00
SW
SW201002 GBP 100.00 100.00
SW201151 GBP 100.00 100.00
SW211111 GBP 200.00 200.00
SW311501 GBP 200.00 200.00
SW402001 GBP 200.00 200.00
SW
Name JB
19/09/2005 00:00 Currency GBP Pound Sterling Report :
6 7.00



Item Price in Currency Description
Amount1 Amount2
JB101101 GBP Fridge 1000.00 1000.00
JB170101 GBP Washing Machine 200.00 200.00
JB201001 GBP Fund Transfer In 300.00 300.00
JB
JB201002 GBP 100.00 100.00
JB201151 GBP 100.00 100.00
JB211111 GBP 200.00 200.00
JB311501 GBP 200.00 200.00
JB402001 GBP 200.00 200.00

Sorry if this looks a mess but as long as the macro starts and stops
and then starts again this should work however I think this will be a
big challenge......I spent around 3 days trying to do this using
recorded macro but it just wont work so I give up!

Hope someone can help,

Kind Regards,

Stu

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      1st Nov 2006
Sub AddName()
Dim sAddr As String
Dim v() As Range, i As Long
Dim rng As Range, rng2 As Range
Dim rng1 As Range, rng3 As Range
Set rng = Columns(2).Find( _
What:="Name", _
After:=Cells(Rows.Count, 2), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
ReDim v(1 To 1)
If Not rng Is Nothing Then
sAddr = rng.Address
Do
Set v(UBound(v)) = rng
ReDim Preserve v(1 To UBound(v) + 1)
Set rng = Columns(2).FindNext(rng)
Loop While rng.Address <> sAddr
Set v(UBound(v)) = Cells(Rows.Count, 2).End(xlUp)(2)
For i = 1 To UBound(v) - 1
Set rng1 = Range(v(i), v(i + 1))
Set rng2 = Nothing
On Error Resume Next
Set rng2 = rng1.SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0
If Not rng2 Is Nothing Then
Set rng3 = Intersect(rng2.EntireRow, Columns(1))
rng3.Value = v(i).Offset(0, 1)
End If
Next
End If
End Sub

worked for me with the data you show and what you described.

--
Regards,
Tom Ogilvy


"Stuart" wrote:

> I have data in excel. I have a combine macro to combine a hundred
> spreadsheets in excel.
>
> This works no problem however...............
>
> The data at the moment in excel looks like,
>
>
>
> Name SW
> Report : 6
>
>
>
> Item Price in Currency Description
> Amount1 Amount2
> 101101 GBP Fridge 1000.00 1000.00
> 170101 GBP Washing Machine 200.00 200.00
> 201001 GBP Fund Transfer In 300.00 300.00
>
> 201002 GBP 100.00 100.00
> 201151 GBP 100.00 100.00
> 211111 GBP 200.00 200.00
> 311501 GBP 200.00 200.00
> 402001 GBP 200.00 200.00
>
> Name JB
> 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> 6 7.00
>
>
>
> Item Price in Currency Description
> Amount1 Amount2
> 101101 GBP Fridge 1000.00 1000.00
> 170101 GBP Washing Machine 200.00 200.00
> 201001 GBP Fund Transfer In 300.00 300.00
>
> 201002 GBP 100.00 100.00
> 201151 GBP 100.00 100.00
> 211111 GBP 200.00 200.00
> 311501 GBP 200.00 200.00
> 402001 GBP 200.00 200.00
>
>
> What I need from a macro is that everytime it finds the word "Name" in
> column B it will pick up the cell to the right of that and then paste
> it down the account numbers until it sees the word item and then does
> the same again.
>
> The expected output from the macro working would be :
>
> Name SW
> Report : 6
>
>
>
> Item Price in Currency Description
> Amount1 Amount2
> SW101101 GBP Fridge 1000.00 1000.00
> SW170101 GBP Washing Machine 200.00 200.00
> SW201001 GBP Fund Transfer In 300.00 300.00
> SW
> SW201002 GBP 100.00 100.00
> SW201151 GBP 100.00 100.00
> SW211111 GBP 200.00 200.00
> SW311501 GBP 200.00 200.00
> SW402001 GBP 200.00 200.00
> SW
> Name JB
> 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> 6 7.00
>
>
>
> Item Price in Currency Description
> Amount1 Amount2
> JB101101 GBP Fridge 1000.00 1000.00
> JB170101 GBP Washing Machine 200.00 200.00
> JB201001 GBP Fund Transfer In 300.00 300.00
> JB
> JB201002 GBP 100.00 100.00
> JB201151 GBP 100.00 100.00
> JB211111 GBP 200.00 200.00
> JB311501 GBP 200.00 200.00
> JB402001 GBP 200.00 200.00
>
> Sorry if this looks a mess but as long as the macro starts and stops
> and then starts again this should work however I think this will be a
> big challenge......I spent around 3 days trying to do this using
> recorded macro but it just wont work so I give up!
>
> Hope someone can help,
>
> Kind Regards,
>
> Stu
>
>

 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      1st Nov 2006
Hi Tom,

Thanks for the reply,

That macro did nothing at all,

All I changed was what it was to find "Name" as this is not what my
data is. Came up with no errors at all.

Is there something missing?

I just need the macro to find a cell and then take the cell next to
that and paste down column A until it finds the next row containing the
word "Name" (as example) and then do the same thing again.

Hope you can help,

Thanks

Stuart

Tom Ogilvy wrote:
> Sub AddName()
> Dim sAddr As String
> Dim v() As Range, i As Long
> Dim rng As Range, rng2 As Range
> Dim rng1 As Range, rng3 As Range
> Set rng = Columns(2).Find( _
> What:="Name", _
> After:=Cells(Rows.Count, 2), _
> LookIn:=xlFormulas, _
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, _
> SearchDirection:=xlNext, _
> MatchCase:=False)
> ReDim v(1 To 1)
> If Not rng Is Nothing Then
> sAddr = rng.Address
> Do
> Set v(UBound(v)) = rng
> ReDim Preserve v(1 To UBound(v) + 1)
> Set rng = Columns(2).FindNext(rng)
> Loop While rng.Address <> sAddr
> Set v(UBound(v)) = Cells(Rows.Count, 2).End(xlUp)(2)
> For i = 1 To UBound(v) - 1
> Set rng1 = Range(v(i), v(i + 1))
> Set rng2 = Nothing
> On Error Resume Next
> Set rng2 = rng1.SpecialCells(xlConstants, xlNumbers)
> On Error GoTo 0
> If Not rng2 Is Nothing Then
> Set rng3 = Intersect(rng2.EntireRow, Columns(1))
> rng3.Value = v(i).Offset(0, 1)
> End If
> Next
> End If
> End Sub
>
> worked for me with the data you show and what you described.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Stuart" wrote:
>
> > I have data in excel. I have a combine macro to combine a hundred
> > spreadsheets in excel.
> >
> > This works no problem however...............
> >
> > The data at the moment in excel looks like,
> >
> >
> >
> > Name SW
> > Report : 6
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > 101101 GBP Fridge 1000.00 1000.00
> > 170101 GBP Washing Machine 200.00 200.00
> > 201001 GBP Fund Transfer In 300.00 300.00
> >
> > 201002 GBP 100.00 100.00
> > 201151 GBP 100.00 100.00
> > 211111 GBP 200.00 200.00
> > 311501 GBP 200.00 200.00
> > 402001 GBP 200.00 200.00
> >
> > Name JB
> > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > 6 7.00
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > 101101 GBP Fridge 1000.00 1000.00
> > 170101 GBP Washing Machine 200.00 200.00
> > 201001 GBP Fund Transfer In 300.00 300.00
> >
> > 201002 GBP 100.00 100.00
> > 201151 GBP 100.00 100.00
> > 211111 GBP 200.00 200.00
> > 311501 GBP 200.00 200.00
> > 402001 GBP 200.00 200.00
> >
> >
> > What I need from a macro is that everytime it finds the word "Name" in
> > column B it will pick up the cell to the right of that and then paste
> > it down the account numbers until it sees the word item and then does
> > the same again.
> >
> > The expected output from the macro working would be :
> >
> > Name SW
> > Report : 6
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > SW101101 GBP Fridge 1000.00 1000.00
> > SW170101 GBP Washing Machine 200.00 200.00
> > SW201001 GBP Fund Transfer In 300.00 300.00
> > SW
> > SW201002 GBP 100.00 100.00
> > SW201151 GBP 100.00 100.00
> > SW211111 GBP 200.00 200.00
> > SW311501 GBP 200.00 200.00
> > SW402001 GBP 200.00 200.00
> > SW
> > Name JB
> > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > 6 7.00
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > JB101101 GBP Fridge 1000.00 1000.00
> > JB170101 GBP Washing Machine 200.00 200.00
> > JB201001 GBP Fund Transfer In 300.00 300.00
> > JB
> > JB201002 GBP 100.00 100.00
> > JB201151 GBP 100.00 100.00
> > JB211111 GBP 200.00 200.00
> > JB311501 GBP 200.00 200.00
> > JB402001 GBP 200.00 200.00
> >
> > Sorry if this looks a mess but as long as the macro starts and stops
> > and then starts again this should work however I think this will be a
> > big challenge......I spent around 3 days trying to do this using
> > recorded macro but it just wont work so I give up!
> >
> > Hope someone can help,
> >
> > Kind Regards,
> >
> > Stu
> >
> >


 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      1st Nov 2006
Hi again Tom,

This may make a difference to you when helping :

the column where macro is to look up is in column "F" and the cell to
be entered down column A is in column G in the cell next to where the
macro has found the word.

I then want word added to the beginning of every cell down column A
until the macro finds the word again. Then it will carry out the same
process until the end of the spreadsheet.

Does this help at all?

Thanks

Stuart
Tom Ogilvy wrote:
> Sub AddName()
> Dim sAddr As String
> Dim v() As Range, i As Long
> Dim rng As Range, rng2 As Range
> Dim rng1 As Range, rng3 As Range
> Set rng = Columns(2).Find( _
> What:="Name", _
> After:=Cells(Rows.Count, 2), _
> LookIn:=xlFormulas, _
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, _
> SearchDirection:=xlNext, _
> MatchCase:=False)
> ReDim v(1 To 1)
> If Not rng Is Nothing Then
> sAddr = rng.Address
> Do
> Set v(UBound(v)) = rng
> ReDim Preserve v(1 To UBound(v) + 1)
> Set rng = Columns(2).FindNext(rng)
> Loop While rng.Address <> sAddr
> Set v(UBound(v)) = Cells(Rows.Count, 2).End(xlUp)(2)
> For i = 1 To UBound(v) - 1
> Set rng1 = Range(v(i), v(i + 1))
> Set rng2 = Nothing
> On Error Resume Next
> Set rng2 = rng1.SpecialCells(xlConstants, xlNumbers)
> On Error GoTo 0
> If Not rng2 Is Nothing Then
> Set rng3 = Intersect(rng2.EntireRow, Columns(1))
> rng3.Value = v(i).Offset(0, 1)
> End If
> Next
> End If
> End Sub
>
> worked for me with the data you show and what you described.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Stuart" wrote:
>
> > I have data in excel. I have a combine macro to combine a hundred
> > spreadsheets in excel.
> >
> > This works no problem however...............
> >
> > The data at the moment in excel looks like,
> >
> >
> >
> > Name SW
> > Report : 6
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > 101101 GBP Fridge 1000.00 1000.00
> > 170101 GBP Washing Machine 200.00 200.00
> > 201001 GBP Fund Transfer In 300.00 300.00
> >
> > 201002 GBP 100.00 100.00
> > 201151 GBP 100.00 100.00
> > 211111 GBP 200.00 200.00
> > 311501 GBP 200.00 200.00
> > 402001 GBP 200.00 200.00
> >
> > Name JB
> > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > 6 7.00
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > 101101 GBP Fridge 1000.00 1000.00
> > 170101 GBP Washing Machine 200.00 200.00
> > 201001 GBP Fund Transfer In 300.00 300.00
> >
> > 201002 GBP 100.00 100.00
> > 201151 GBP 100.00 100.00
> > 211111 GBP 200.00 200.00
> > 311501 GBP 200.00 200.00
> > 402001 GBP 200.00 200.00
> >
> >
> > What I need from a macro is that everytime it finds the word "Name" in
> > column B it will pick up the cell to the right of that and then paste
> > it down the account numbers until it sees the word item and then does
> > the same again.
> >
> > The expected output from the macro working would be :
> >
> > Name SW
> > Report : 6
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > SW101101 GBP Fridge 1000.00 1000.00
> > SW170101 GBP Washing Machine 200.00 200.00
> > SW201001 GBP Fund Transfer In 300.00 300.00
> > SW
> > SW201002 GBP 100.00 100.00
> > SW201151 GBP 100.00 100.00
> > SW211111 GBP 200.00 200.00
> > SW311501 GBP 200.00 200.00
> > SW402001 GBP 200.00 200.00
> > SW
> > Name JB
> > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > 6 7.00
> >
> >
> >
> > Item Price in Currency Description
> > Amount1 Amount2
> > JB101101 GBP Fridge 1000.00 1000.00
> > JB170101 GBP Washing Machine 200.00 200.00
> > JB201001 GBP Fund Transfer In 300.00 300.00
> > JB
> > JB201002 GBP 100.00 100.00
> > JB201151 GBP 100.00 100.00
> > JB211111 GBP 200.00 200.00
> > JB311501 GBP 200.00 200.00
> > JB402001 GBP 200.00 200.00
> >
> > Sorry if this looks a mess but as long as the macro starts and stops
> > and then starts again this should work however I think this will be a
> > big challenge......I spent around 3 days trying to do this using
> > recorded macro but it just wont work so I give up!
> >
> > Hope someone can help,
> >
> > Kind Regards,
> >
> > Stu
> >
> >


 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      1st Nov 2006
Maybe this will help you get it working.

This what you said you wanted:

>What I need from a macro is that everytime it finds the word "Name" in
>column B it will pick up the cell to the right of that and then paste
>it down the account numbers until it sees the word item and then does
>the same again.


I would modify it according to your newly revealed changes, but there are
probably more differences which you haven't reveal. With a little effort,
you should be able to modify it.

If not, put my original code in a workbook with sample data and send it to
me at (E-Mail Removed)

--
Regards,
Tom Ogilvy




"Stuart" wrote:

> Hi again Tom,
>
> This may make a difference to you when helping :
>
> the column where macro is to look up is in column "F" and the cell to
> be entered down column A is in column G in the cell next to where the
> macro has found the word.
>
> I then want word added to the beginning of every cell down column A
> until the macro finds the word again. Then it will carry out the same
> process until the end of the spreadsheet.
>
> Does this help at all?
>
> Thanks
>
> Stuart
> Tom Ogilvy wrote:
> > Sub AddName()
> > Dim sAddr As String
> > Dim v() As Range, i As Long
> > Dim rng As Range, rng2 As Range
> > Dim rng1 As Range, rng3 As Range
> > Set rng = Columns(2).Find( _
> > What:="Name", _
> > After:=Cells(Rows.Count, 2), _
> > LookIn:=xlFormulas, _
> > LookAt:=xlPart, _
> > SearchOrder:=xlByRows, _
> > SearchDirection:=xlNext, _
> > MatchCase:=False)
> > ReDim v(1 To 1)
> > If Not rng Is Nothing Then
> > sAddr = rng.Address
> > Do
> > Set v(UBound(v)) = rng
> > ReDim Preserve v(1 To UBound(v) + 1)
> > Set rng = Columns(2).FindNext(rng)
> > Loop While rng.Address <> sAddr
> > Set v(UBound(v)) = Cells(Rows.Count, 2).End(xlUp)(2)
> > For i = 1 To UBound(v) - 1
> > Set rng1 = Range(v(i), v(i + 1))
> > Set rng2 = Nothing
> > On Error Resume Next
> > Set rng2 = rng1.SpecialCells(xlConstants, xlNumbers)
> > On Error GoTo 0
> > If Not rng2 Is Nothing Then
> > Set rng3 = Intersect(rng2.EntireRow, Columns(1))
> > rng3.Value = v(i).Offset(0, 1)
> > End If
> > Next
> > End If
> > End Sub
> >
> > worked for me with the data you show and what you described.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Stuart" wrote:
> >
> > > I have data in excel. I have a combine macro to combine a hundred
> > > spreadsheets in excel.
> > >
> > > This works no problem however...............
> > >
> > > The data at the moment in excel looks like,
> > >
> > >
> > >
> > > Name SW
> > > Report : 6
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > 101101 GBP Fridge 1000.00 1000.00
> > > 170101 GBP Washing Machine 200.00 200.00
> > > 201001 GBP Fund Transfer In 300.00 300.00
> > >
> > > 201002 GBP 100.00 100.00
> > > 201151 GBP 100.00 100.00
> > > 211111 GBP 200.00 200.00
> > > 311501 GBP 200.00 200.00
> > > 402001 GBP 200.00 200.00
> > >
> > > Name JB
> > > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > > 6 7.00
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > 101101 GBP Fridge 1000.00 1000.00
> > > 170101 GBP Washing Machine 200.00 200.00
> > > 201001 GBP Fund Transfer In 300.00 300.00
> > >
> > > 201002 GBP 100.00 100.00
> > > 201151 GBP 100.00 100.00
> > > 211111 GBP 200.00 200.00
> > > 311501 GBP 200.00 200.00
> > > 402001 GBP 200.00 200.00
> > >
> > >
> > > What I need from a macro is that everytime it finds the word "Name" in
> > > column B it will pick up the cell to the right of that and then paste
> > > it down the account numbers until it sees the word item and then does
> > > the same again.
> > >
> > > The expected output from the macro working would be :
> > >
> > > Name SW
> > > Report : 6
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > SW101101 GBP Fridge 1000.00 1000.00
> > > SW170101 GBP Washing Machine 200.00 200.00
> > > SW201001 GBP Fund Transfer In 300.00 300.00
> > > SW
> > > SW201002 GBP 100.00 100.00
> > > SW201151 GBP 100.00 100.00
> > > SW211111 GBP 200.00 200.00
> > > SW311501 GBP 200.00 200.00
> > > SW402001 GBP 200.00 200.00
> > > SW
> > > Name JB
> > > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > > 6 7.00
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > JB101101 GBP Fridge 1000.00 1000.00
> > > JB170101 GBP Washing Machine 200.00 200.00
> > > JB201001 GBP Fund Transfer In 300.00 300.00
> > > JB
> > > JB201002 GBP 100.00 100.00
> > > JB201151 GBP 100.00 100.00
> > > JB211111 GBP 200.00 200.00
> > > JB311501 GBP 200.00 200.00
> > > JB402001 GBP 200.00 200.00
> > >
> > > Sorry if this looks a mess but as long as the macro starts and stops
> > > and then starts again this should work however I think this will be a
> > > big challenge......I spent around 3 days trying to do this using
> > > recorded macro but it just wont work so I give up!
> > >
> > > Hope someone can help,
> > >
> > > Kind Regards,
> > >
> > > Stu
> > >
> > >

>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      1st Nov 2006
> All I changed was what it was to find "Name" as this is not what my
> data is.


Based on your latest post, how about changing the location of where the
information is located - you think that my affect the ability to process your
data. Just a guess.


--
Regards,
Tom Ogilvy



"Stuart" wrote:

> Hi Tom,
>
> Thanks for the reply,
>
> That macro did nothing at all,
>
> All I changed was what it was to find "Name" as this is not what my
> data is. Came up with no errors at all.
>
> Is there something missing?
>
> I just need the macro to find a cell and then take the cell next to
> that and paste down column A until it finds the next row containing the
> word "Name" (as example) and then do the same thing again.
>
> Hope you can help,
>
> Thanks
>
> Stuart
>
> Tom Ogilvy wrote:
> > Sub AddName()
> > Dim sAddr As String
> > Dim v() As Range, i As Long
> > Dim rng As Range, rng2 As Range
> > Dim rng1 As Range, rng3 As Range
> > Set rng = Columns(2).Find( _
> > What:="Name", _
> > After:=Cells(Rows.Count, 2), _
> > LookIn:=xlFormulas, _
> > LookAt:=xlPart, _
> > SearchOrder:=xlByRows, _
> > SearchDirection:=xlNext, _
> > MatchCase:=False)
> > ReDim v(1 To 1)
> > If Not rng Is Nothing Then
> > sAddr = rng.Address
> > Do
> > Set v(UBound(v)) = rng
> > ReDim Preserve v(1 To UBound(v) + 1)
> > Set rng = Columns(2).FindNext(rng)
> > Loop While rng.Address <> sAddr
> > Set v(UBound(v)) = Cells(Rows.Count, 2).End(xlUp)(2)
> > For i = 1 To UBound(v) - 1
> > Set rng1 = Range(v(i), v(i + 1))
> > Set rng2 = Nothing
> > On Error Resume Next
> > Set rng2 = rng1.SpecialCells(xlConstants, xlNumbers)
> > On Error GoTo 0
> > If Not rng2 Is Nothing Then
> > Set rng3 = Intersect(rng2.EntireRow, Columns(1))
> > rng3.Value = v(i).Offset(0, 1)
> > End If
> > Next
> > End If
> > End Sub
> >
> > worked for me with the data you show and what you described.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Stuart" wrote:
> >
> > > I have data in excel. I have a combine macro to combine a hundred
> > > spreadsheets in excel.
> > >
> > > This works no problem however...............
> > >
> > > The data at the moment in excel looks like,
> > >
> > >
> > >
> > > Name SW
> > > Report : 6
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > 101101 GBP Fridge 1000.00 1000.00
> > > 170101 GBP Washing Machine 200.00 200.00
> > > 201001 GBP Fund Transfer In 300.00 300.00
> > >
> > > 201002 GBP 100.00 100.00
> > > 201151 GBP 100.00 100.00
> > > 211111 GBP 200.00 200.00
> > > 311501 GBP 200.00 200.00
> > > 402001 GBP 200.00 200.00
> > >
> > > Name JB
> > > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > > 6 7.00
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > 101101 GBP Fridge 1000.00 1000.00
> > > 170101 GBP Washing Machine 200.00 200.00
> > > 201001 GBP Fund Transfer In 300.00 300.00
> > >
> > > 201002 GBP 100.00 100.00
> > > 201151 GBP 100.00 100.00
> > > 211111 GBP 200.00 200.00
> > > 311501 GBP 200.00 200.00
> > > 402001 GBP 200.00 200.00
> > >
> > >
> > > What I need from a macro is that everytime it finds the word "Name" in
> > > column B it will pick up the cell to the right of that and then paste
> > > it down the account numbers until it sees the word item and then does
> > > the same again.
> > >
> > > The expected output from the macro working would be :
> > >
> > > Name SW
> > > Report : 6
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > SW101101 GBP Fridge 1000.00 1000.00
> > > SW170101 GBP Washing Machine 200.00 200.00
> > > SW201001 GBP Fund Transfer In 300.00 300.00
> > > SW
> > > SW201002 GBP 100.00 100.00
> > > SW201151 GBP 100.00 100.00
> > > SW211111 GBP 200.00 200.00
> > > SW311501 GBP 200.00 200.00
> > > SW402001 GBP 200.00 200.00
> > > SW
> > > Name JB
> > > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > > 6 7.00
> > >
> > >
> > >
> > > Item Price in Currency Description
> > > Amount1 Amount2
> > > JB101101 GBP Fridge 1000.00 1000.00
> > > JB170101 GBP Washing Machine 200.00 200.00
> > > JB201001 GBP Fund Transfer In 300.00 300.00
> > > JB
> > > JB201002 GBP 100.00 100.00
> > > JB201151 GBP 100.00 100.00
> > > JB211111 GBP 200.00 200.00
> > > JB311501 GBP 200.00 200.00
> > > JB402001 GBP 200.00 200.00
> > >
> > > Sorry if this looks a mess but as long as the macro starts and stops
> > > and then starts again this should work however I think this will be a
> > > big challenge......I spent around 3 days trying to do this using
> > > recorded macro but it just wont work so I give up!
> > >
> > > Hope someone can help,
> > >
> > > Kind Regards,
> > >
> > > Stu
> > >
> > >

>
>

 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      1st Nov 2006
Hi Tom,

I sent you an email,

i have tried most of today to manipulate your macro but the thing just
wouldnt do anything for me at all,

Sorry to be a pain!

Kind Regards,

Stuart Wilson

Tom Ogilvy wrote:
> Maybe this will help you get it working.
>
> This what you said you wanted:
>
> >What I need from a macro is that everytime it finds the word "Name" in
> >column B it will pick up the cell to the right of that and then paste
> >it down the account numbers until it sees the word item and then does
> >the same again.

>
> I would modify it according to your newly revealed changes, but there are
> probably more differences which you haven't reveal. With a little effort,
> you should be able to modify it.
>
> If not, put my original code in a workbook with sample data and send it to
> me at (E-Mail Removed)
>
> --
> Regards,
> Tom Ogilvy
>
>
>
>
> "Stuart" wrote:
>
> > Hi again Tom,
> >
> > This may make a difference to you when helping :
> >
> > the column where macro is to look up is in column "F" and the cell to
> > be entered down column A is in column G in the cell next to where the
> > macro has found the word.
> >
> > I then want word added to the beginning of every cell down column A
> > until the macro finds the word again. Then it will carry out the same
> > process until the end of the spreadsheet.
> >
> > Does this help at all?
> >
> > Thanks
> >
> > Stuart
> > Tom Ogilvy wrote:
> > > Sub AddName()
> > > Dim sAddr As String
> > > Dim v() As Range, i As Long
> > > Dim rng As Range, rng2 As Range
> > > Dim rng1 As Range, rng3 As Range
> > > Set rng = Columns(2).Find( _
> > > What:="Name", _
> > > After:=Cells(Rows.Count, 2), _
> > > LookIn:=xlFormulas, _
> > > LookAt:=xlPart, _
> > > SearchOrder:=xlByRows, _
> > > SearchDirection:=xlNext, _
> > > MatchCase:=False)
> > > ReDim v(1 To 1)
> > > If Not rng Is Nothing Then
> > > sAddr = rng.Address
> > > Do
> > > Set v(UBound(v)) = rng
> > > ReDim Preserve v(1 To UBound(v) + 1)
> > > Set rng = Columns(2).FindNext(rng)
> > > Loop While rng.Address <> sAddr
> > > Set v(UBound(v)) = Cells(Rows.Count, 2).End(xlUp)(2)
> > > For i = 1 To UBound(v) - 1
> > > Set rng1 = Range(v(i), v(i + 1))
> > > Set rng2 = Nothing
> > > On Error Resume Next
> > > Set rng2 = rng1.SpecialCells(xlConstants, xlNumbers)
> > > On Error GoTo 0
> > > If Not rng2 Is Nothing Then
> > > Set rng3 = Intersect(rng2.EntireRow, Columns(1))
> > > rng3.Value = v(i).Offset(0, 1)
> > > End If
> > > Next
> > > End If
> > > End Sub
> > >
> > > worked for me with the data you show and what you described.
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "Stuart" wrote:
> > >
> > > > I have data in excel. I have a combine macro to combine a hundred
> > > > spreadsheets in excel.
> > > >
> > > > This works no problem however...............
> > > >
> > > > The data at the moment in excel looks like,
> > > >
> > > >
> > > >
> > > > Name SW
> > > > Report : 6
> > > >
> > > >
> > > >
> > > > Item Price in Currency Description
> > > > Amount1 Amount2
> > > > 101101 GBP Fridge 1000.00 1000.00
> > > > 170101 GBP Washing Machine 200.00 200.00
> > > > 201001 GBP Fund Transfer In 300.00 300.00
> > > >
> > > > 201002 GBP 100.00 100.00
> > > > 201151 GBP 100.00 100.00
> > > > 211111 GBP 200.00 200.00
> > > > 311501 GBP 200.00 200.00
> > > > 402001 GBP 200.00 200.00
> > > >
> > > > Name JB
> > > > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > > > 6 7.00
> > > >
> > > >
> > > >
> > > > Item Price in Currency Description
> > > > Amount1 Amount2
> > > > 101101 GBP Fridge 1000.00 1000.00
> > > > 170101 GBP Washing Machine 200.00 200.00
> > > > 201001 GBP Fund Transfer In 300.00 300.00
> > > >
> > > > 201002 GBP 100.00 100.00
> > > > 201151 GBP 100.00 100.00
> > > > 211111 GBP 200.00 200.00
> > > > 311501 GBP 200.00 200.00
> > > > 402001 GBP 200.00 200.00
> > > >
> > > >
> > > > What I need from a macro is that everytime it finds the word "Name" in
> > > > column B it will pick up the cell to the right of that and then paste
> > > > it down the account numbers until it sees the word item and then does
> > > > the same again.
> > > >
> > > > The expected output from the macro working would be :
> > > >
> > > > Name SW
> > > > Report : 6
> > > >
> > > >
> > > >
> > > > Item Price in Currency Description
> > > > Amount1 Amount2
> > > > SW101101 GBP Fridge 1000.00 1000.00
> > > > SW170101 GBP Washing Machine 200.00 200.00
> > > > SW201001 GBP Fund Transfer In 300.00 300.00
> > > > SW
> > > > SW201002 GBP 100.00 100.00
> > > > SW201151 GBP 100.00 100.00
> > > > SW211111 GBP 200.00 200.00
> > > > SW311501 GBP 200.00 200.00
> > > > SW402001 GBP 200.00 200.00
> > > > SW
> > > > Name JB
> > > > 19/09/2005 00:00 Currency GBP Pound Sterling Report :
> > > > 6 7.00
> > > >
> > > >
> > > >
> > > > Item Price in Currency Description
> > > > Amount1 Amount2
> > > > JB101101 GBP Fridge 1000.00 1000.00
> > > > JB170101 GBP Washing Machine 200.00 200.00
> > > > JB201001 GBP Fund Transfer In 300.00 300.00
> > > > JB
> > > > JB201002 GBP 100.00 100.00
> > > > JB201151 GBP 100.00 100.00
> > > > JB211111 GBP 200.00 200.00
> > > > JB311501 GBP 200.00 200.00
> > > > JB402001 GBP 200.00 200.00
> > > >
> > > > Sorry if this looks a mess but as long as the macro starts and stops
> > > > and then starts again this should work however I think this will be a
> > > > big challenge......I spent around 3 days trying to do this using
> > > > recorded macro but it just wont work so I give up!
> > > >
> > > > Hope someone can help,
> > > >
> > > > Kind Regards,
> > > >
> > > > Stu
> > > >
> > > >

> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you help me with this macro challenge? excelgrrl Microsoft Excel Programming 0 23rd Jan 2008 05:03 AM
Complicated Challenge lee6553 Microsoft Excel Misc 7 21st Jul 2005 02:55 PM
*Complicated Outlook Challenge* Animatrix1 Microsoft Outlook Contacts 5 7th Apr 2004 09:18 PM
Macro Challenge! posborne Microsoft Excel Misc 5 12th Jan 2004 05:30 PM
Macro challenge Gregg G Microsoft Excel Programming 0 10th Oct 2003 07:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:19 PM.