#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Stuck!

I have what I would say is a easy problem to solve but I can't!. I want to
run a macro that will automatically 'copy paste special values' all cells in
a row between B* and Z* if the value in A* equates to a value in Cell A2.
This will be run over several worksheets



Any ideas?



Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Stuck!

Your problem statement leaves a lot of ambiguity, but perhaps you can
adapt this:
'


Public Sub CopyStuff()
Dim rCell As Range
Dim rDest As Range
Dim wsSheet As Worksheet
Dim dTest As Double

dTest = Worksheets("Sheet1").Range("A2").Value
Set rDest = Worksheets("Sheet1").Range("A5").Resize(, 25)
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3", "Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
With rCell
If .Value = dTest Then
rDest.Value = _
.Offset(0, 1).Resize(, 25).Value
Set rDest = rDest.Offset(1, 0)
End If
End With
Next rCell
End With
Next wsSheet
End Sub

This copies rows from B* to Z* in sheets 2,3 and 5 for which the value
in A* equals the value in Sheet1, cell A2. It copies the values to
Sheet1, beginning at cell A5.



In article ,
"John" wrote:

I have what I would say is a easy problem to solve but I can't!. I want to
run a macro that will automatically 'copy paste special values' all cells in
a row between B* and Z* if the value in A* equates to a value in Cell A2.
This will be run over several worksheets



Any ideas?



Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Stuck!

Thanks for your reply. I probably should have included that the 'copy paste
values' is required in the same cells (what I'm doing is converting formulas
in these cells to the values that they have calculated

Thanks




"JE McGimpsey" wrote in message
...
Your problem statement leaves a lot of ambiguity, but perhaps you can
adapt this:
'


Public Sub CopyStuff()
Dim rCell As Range
Dim rDest As Range
Dim wsSheet As Worksheet
Dim dTest As Double

dTest = Worksheets("Sheet1").Range("A2").Value
Set rDest = Worksheets("Sheet1").Range("A5").Resize(, 25)
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3", "Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
With rCell
If .Value = dTest Then
rDest.Value = _
.Offset(0, 1).Resize(, 25).Value
Set rDest = rDest.Offset(1, 0)
End If
End With
Next rCell
End With
Next wsSheet
End Sub

This copies rows from B* to Z* in sheets 2,3 and 5 for which the value
in A* equals the value in Sheet1, cell A2. It copies the values to
Sheet1, beginning at cell A5.



In article ,
"John" wrote:

I have what I would say is a easy problem to solve but I can't!. I want

to
run a macro that will automatically 'copy paste special values' all

cells in
a row between B* and Z* if the value in A* equates to a value in Cell

A2.
This will be run over several worksheets



Any ideas?



Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Stuck!

That's a bit easier:

Public Sub EliminateFormulae()
Dim wsSheet As Worksheet
Dim dTest As Double
dTest = Worksheets("Sheet1").Range("A2").Value
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3", "Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value = dTest Then
With rCell.Offset(0, 1).Resize(, 25)
.Value = .Value
End With
End If
Next rCell
End With
Next wsSheet
End Sub


In article ,
"John" wrote:

Thanks for your reply. I probably should have included that the 'copy paste
values' is required in the same cells (what I'm doing is converting formulas
in these cells to the values that they have calculated

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Stuck!

Works a treat JE thanks for that

"JE McGimpsey" wrote in message
...
That's a bit easier:

Public Sub EliminateFormulae()
Dim wsSheet As Worksheet
Dim dTest As Double
dTest = Worksheets("Sheet1").Range("A2").Value
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3", "Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value = dTest Then
With rCell.Offset(0, 1).Resize(, 25)
.Value = .Value
End With
End If
Next rCell
End With
Next wsSheet
End Sub


In article ,
"John" wrote:

Thanks for your reply. I probably should have included that the 'copy

paste
values' is required in the same cells (what I'm doing is converting

formulas
in these cells to the values that they have calculated





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Stuck!

One slight problem, it seems to continue across all columns if there is a
formula within i.e. from B* out. How do I get it to stop 'copy-paste-values'
at say column D?

Thanks


"John" wrote in message
...
Works a treat JE thanks for that

"JE McGimpsey" wrote in message
...
That's a bit easier:

Public Sub EliminateFormulae()
Dim wsSheet As Worksheet
Dim dTest As Double
dTest = Worksheets("Sheet1").Range("A2").Value
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3", "Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value = dTest Then
With rCell.Offset(0, 1).Resize(, 25)
.Value = .Value
End With
End If
Next rCell
End With
Next wsSheet
End Sub


In article ,
"John" wrote:

Thanks for your reply. I probably should have included that the 'copy

paste
values' is required in the same cells (what I'm doing is converting

formulas
in these cells to the values that they have calculated





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Stuck!

Worked it out Resize(, 25) = Column numbers

Thanks


"John" wrote in message
...
One slight problem, it seems to continue across all columns if there is a
formula within i.e. from B* out. How do I get it to stop

'copy-paste-values'
at say column D?

Thanks


"John" wrote in message
...
Works a treat JE thanks for that

"JE McGimpsey" wrote in message
...
That's a bit easier:

Public Sub EliminateFormulae()
Dim wsSheet As Worksheet
Dim dTest As Double
dTest = Worksheets("Sheet1").Range("A2").Value
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3",

"Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value = dTest Then
With rCell.Offset(0, 1).Resize(, 25)
.Value = .Value
End With
End If
Next rCell
End With
Next wsSheet
End Sub


In article ,
"John" wrote:

Thanks for your reply. I probably should have included that the

'copy
paste
values' is required in the same cells (what I'm doing is converting

formulas
in these cells to the values that they have calculated







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stuck!

In using the the formula to value I get stuck on (For Each rCell ) Message
Compile Error Can find project or Library


"John" wrote in message
...
Worked it out Resize(, 25) = Column numbers

Thanks


"John" wrote in message
...
One slight problem, it seems to continue across all columns if there is

a
formula within i.e. from B* out. How do I get it to stop

'copy-paste-values'
at say column D?

Thanks


"John" wrote in message
...
Works a treat JE thanks for that

"JE McGimpsey" wrote in message
...
That's a bit easier:

Public Sub EliminateFormulae()
Dim wsSheet As Worksheet
Dim dTest As Double
dTest = Worksheets("Sheet1").Range("A2").Value
For Each wsSheet In Sheets(Array("Sheet2", "Sheet3",

"Sheet5"))
With wsSheet
For Each rCell In .Range("A1:A" & _
.Range("A" & Rows.Count).End(xlUp).Row)
If rCell.Value = dTest Then
With rCell.Offset(0, 1).Resize(, 25)
.Value = .Value
End With
End If
Next rCell
End With
Next wsSheet
End Sub


In article ,
"John" wrote:

Thanks for your reply. I probably should have included that the

'copy
paste
values' is required in the same cells (what I'm doing is

converting
formulas
in these cells to the values that they have calculated








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry but i am stuck again KODIAK BEAR New Users to Excel 5 October 1st 07 08:46 PM
This ones got me stuck DB Excel Worksheet Functions 4 April 4th 07 09:25 PM
Help, please, I'm stuck Harvest Excel Discussion (Misc queries) 3 August 19th 06 03:28 AM
Stuck... Mike Excel Discussion (Misc queries) 4 May 22nd 06 08:09 PM
Stuck with an =IF Mark R... Excel Worksheet Functions 2 January 25th 06 04:41 PM


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"