Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro that repeats 4 relatively straighforward steps until end of list

Hi - I am getting a refresher on building macros. Below is a list of steps that I am trying to automate. I am wondering if someone would be able to show me what is an efficient macro to use to complete these steps.

I am happy to send the file over, if it makes it easier to follow.

Sheet1 is where the results will be generated based on a single Input Cell (A2), and it has formulas in it that generate the results in column F (F2 thru F40, though ideally the macro would allow flexibility to make the range shorter or longer, such as F2 thru F10, or F2 thru F100. But the only cell that changes in this sheet will be Cell A2.

Sheet2 is simply a list of input values in column A, in the range of A1:A2473. These values in sheet 2 will be pasted into sheet1!A2, but one at a time, generating different results in column F of Sheet1 (due to formulas in that sheet). The values will go into Sheet1!A2, one at a time.

Sheet3! is where the results will be pasted from Sheet1! A list of resulting values will be appended to in sheet3 (i.e., a long list in column A), with the results that are generated in Sheet1, column F.

So the exact list of steps is as follows:

1. Copy the value in Sheet2!A1
2. Paste Result of that cell into Sheet1!A2
3. Copy any cells that contain values in Sheet1!F2:F40 (though preferably allow flexible range of more or less values)
4. Paste (Special Values) those results from Sheet1!F2:F40 into Sheet3!A1:A39

//BEGIN TO REPEAT THE PROCESS, but moving down one cell in Sheet2 to the next value in the list

5. Copy the value in Sheet2!A2 (i.e., offset down 1 cell from step 1, etc..)
6. Paste Result of that cell into Sheet1!A2 (this cell stays the same, and continues to receive the results for each value that is in Sheet2, one by one)
7. Copy any cells that contain values in Sheet1!F2:F40 (though preferably allow flexible range of more or less values)
8. Paste (Special Values) those results from Sheet1!F2:F40 into Sheet3!A40:A79 (i.e., Jump to end of last paste that occurred and continue to append this list with each successive iteration.

Thanks for any assistance! Just let me know if those steps are unclear.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macro that repeats 4 relatively straighforward steps until end of list

Hi Fred,

Am Sun, 10 May 2015 08:57:46 -0700 (PDT) schriebst du in
microsoft.public.excel.programming:

1. Copy the value in Sheet2!A1
2. Paste Result of that cell into Sheet1!A2
3. Copy any cells that contain values in Sheet1!F2:F40 (though preferably allow flexible range of more or less values)
4. Paste (Special Values) those results from Sheet1!F2:F40 into Sheet3!A1:A39


try:

Sub Test()
Dim LRow1 As Long, LRow2 As Long, LRow3 As Long
Dim i As Long

Application.ScreenUpdating = False
With Sheets("Sheet2")
LRow2 = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LRow2
Sheets("Sheet1").Range("A2") = .Cells(i, 1)
LRow1 = Sheets("Sheet1").Cells(Rows.Count, "F").End(xlUp).Row
LRow3 = Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Sheet1").Range("F2:F" & LRow1).Copy _
Destination:=IIf(LRow3 = 1, Sheets("Sheet3").Range("A1"), _
Sheets("Sheet3").Cells(LRow3, 1)(2))
Next
End With
Application.ScreenUpdating = True
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro that repeats 4 relatively straighforward steps until end of list



Thanks very much for the response Claus.

It seems to have worked as intended...except for one exception. The values didn't seem to PasteSpecialvalues.

Instead, each of the results in Sheet3 reads: =#REF!&#REF!&#REF!&#REF!&#REF!

This may be because I have formulas in Sheet1!F2:F40. Do you happen to know if I can make a minor tweak to the code so that the values show up?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Macro that repeats 4 relatively straighforward steps until end of list

Sheets("Sheet1").Range("F2:F" & LRow1).Copy
dest.PasteSpecial xlPasteValues


Could also be...

dest.Value = Sheets("Sheet1").Range("F2:F" & LRow1).Value

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macro that repeats 4 relatively straighforward steps until end of list

Hi Garry,

Am Mon, 11 May 2015 15:56:34 -0400 schrieb GS:

Sheets("Sheet1").Range("F2:F" & LRow1).Copy
dest.PasteSpecial xlPasteValues


Could also be...

dest.Value = Sheets("Sheet1").Range("F2:F" & LRow1).Value


dest is a single cell. You had to resize it:

dest.Resize(LRow1 - 1).Value = Sheets("Sheet1").Range("F2:F" & LRow1).Value


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Macro that repeats 4 relatively straighforward steps until end of list

Hi Garry,

Am Mon, 11 May 2015 15:56:34 -0400 schrieb GS:

Sheets("Sheet1").Range("F2:F" & LRow1).Copy
dest.PasteSpecial xlPasteValues


Could also be...

dest.Value = Sheets("Sheet1").Range("F2:F" & LRow1).Value


dest is a single cell. You had to resize it:

dest.Resize(LRow1 - 1).Value = Sheets("Sheet1").Range("F2:F" &
LRow1).Value


Regards
Claus B.


Ah.., didn't notice!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro that repeats 4 relatively straighforward steps until end of list

On Sunday, May 10, 2015 at 10:57:49 AM UTC-5, wrote:
Hi - I am getting a refresher on building macros. Below is a list of steps that I am trying to automate. I am wondering if someone would be able to show me what is an efficient macro to use to complete these steps.

I am happy to send the file over, if it makes it easier to follow.

Sheet1 is where the results will be generated based on a single Input Cell (A2), and it has formulas in it that generate the results in column F (F2 thru F40, though ideally the macro would allow flexibility to make the range shorter or longer, such as F2 thru F10, or F2 thru F100. But the only cell that changes in this sheet will be Cell A2.

Sheet2 is simply a list of input values in column A, in the range of A1:A2473. These values in sheet 2 will be pasted into sheet1!A2, but one at a time, generating different results in column F of Sheet1 (due to formulas in that sheet). The values will go into Sheet1!A2, one at a time.

Sheet3! is where the results will be pasted from Sheet1! A list of resulting values will be appended to in sheet3 (i.e., a long list in column A), with the results that are generated in Sheet1, column F.

So the exact list of steps is as follows:

1. Copy the value in Sheet2!A1
2. Paste Result of that cell into Sheet1!A2
3. Copy any cells that contain values in Sheet1!F2:F40 (though preferably allow flexible range of more or less values)
4. Paste (Special Values) those results from Sheet1!F2:F40 into Sheet3!A1:A39

//BEGIN TO REPEAT THE PROCESS, but moving down one cell in Sheet2 to the next value in the list

5. Copy the value in Sheet2!A2 (i.e., offset down 1 cell from step 1, etc...)
6. Paste Result of that cell into Sheet1!A2 (this cell stays the same, and continues to receive the results for each value that is in Sheet2, one by one)
7. Copy any cells that contain values in Sheet1!F2:F40 (though preferably allow flexible range of more or less values)
8. Paste (Special Values) those results from Sheet1!F2:F40 into Sheet3!A40:A79 (i.e., Jump to end of last paste that occurred and continue to append this list with each successive iteration.

Thanks for any assistance! Just let me know if those steps are unclear.


thanks to both of you!
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
Macro for detect and list palindromes and repeats in letters/numbersstring Luciano Paulino da Silva Excel Programming 5 April 14th 09 05:54 PM
Eliminating repeats from a list sycsummit Excel Programming 18 April 14th 08 06:34 PM
Randomize list of integers beteen 1-x with no repeats JB Excel Discussion (Misc queries) 5 April 22nd 07 06:42 AM
How can I count the number of repeats in a list of data? SouthCarolina Excel Discussion (Misc queries) 7 March 7th 06 10:03 PM
How do I randomize a list without repeats K9CE Excel Discussion (Misc queries) 2 October 13th 05 07:01 PM


All times are GMT +1. The time now is 06:58 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"