Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "If formula" within a loop

I am looking for a way to create a macro that will search though a
column and when it encounters a specific value it performs the
following function.

If EA12 = 1 Then
Range("AP2:AZ2").Select
Selection.Copy
Range("AP12:AZ12").Select
ActiveSheet.Paste

I have not been able to successfully use any looping methods to this
point. Any Ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default "If formula" within a loop

The looping part should be pretty simple. However, I'm not sure what
exactly you want to do with the selection ranges and paste ranges. You can
adjust the first line to the number of rows you want to search through.
I've used 100 as an example.

For r = 1 To 100
If Range("EA" & r).Value = 1 Then
Range("AP2:AZ2").Select
Selection.Copy
Range("AP12:AZ12").Select
ActiveSheet.Paste
End If
Next

Hope this helps.
Paul

"BigWave@AC" wrote in message
oups.com...
I am looking for a way to create a macro that will search though a
column and when it encounters a specific value it performs the
following function.

If EA12 = 1 Then
Range("AP2:AZ2").Select
Selection.Copy
Range("AP12:AZ12").Select
ActiveSheet.Paste

I have not been able to successfully use any looping methods to this
point. Any Ideas?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default "If formula" within a loop

one possible way!

Assumption : search column has no blank values in it!
Dim ws as Worksheets
Dim rg as Range

Set ws = ThisWorkbook.Worksheets("your sheet name")
Set rg = ws.Range("your range start")

Do until IsEmpty(rg)
If rg = 'your value' Then
Range("AP2:AZ2").Select
Selection.Copy
Range("AP12:AZ12").Select
ActiveSheet.Paste
Else
Set rg = rg.Offset(1,0)
End If
Loop

Above is untested so may have 1 or 2 bugs in. Also would be a better idea to
tidy up the Select statements

HTH
Steve

"BigWave@AC" wrote:

I am looking for a way to create a macro that will search though a
column and when it encounters a specific value it performs the
following function.

If EA12 = 1 Then
Range("AP2:AZ2").Select
Selection.Copy
Range("AP12:AZ12").Select
ActiveSheet.Paste

I have not been able to successfully use any looping methods to this
point. Any Ideas?


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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... Maria J-son[_2_] Excel Programming 2 March 5th 06 12:20 PM
LOOP BETWEEN "FRONT" AND "END" SHEETS? ewan7279 Excel Programming 7 March 17th 05 03:11 PM


All times are GMT +1. The time now is 05:16 AM.

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

About Us

"It's about Microsoft Excel"