Hello Gurus... This is my first post and I registered to this forum since I needed some special help. I've been a long time excel user but hardly write macros. I figured I coulduse your expertse on this issue - I wll cut to the chase and define the problem -
Here is my problem - I am trying to supply inputs from sheet1 to sheet2 on a workbook and get the output (based on a formula) and put it back on sheet1 in a specified range of cells and loop this entired process 700 times.
Process -
step1 - I would like to copy values in cells A1,C1,E1,G1,I1,K1,M1 from Sheet1 and paste them into B12:B18 (transposed) on sheet 2.
step 2 - Similarly, I would like to copy values in cells B1,D1,F1,H1,J1,L1 and N1 from sheet 1 and paste them into C12:C18(transposed) on sheet 2
Step 3 - Then I would like to grab/copy (calculated output values) from cells C22:C27 from sheet 2 and paste it back to sheet 1 into cells AB1:AG1 (transposed)
Step 4 - I would like the code to repeat steps 1 2 and 3, in that order, for the values in row 2 (A2), row 3, row 4 and keep doing it one by one uptill row 700.. bacially loop it. Please note that I will be copying values from sheet 1 from different rows each time sequentially but pasting it on the same cells in sheet 2 and pulling the output also from the same cells defined above in step 3
below is what I have but it is not performing as intended - it is unfinished though
Option Explicit
Sub MyCopy()
Dim lngLastRow As Long
Dim lngRow As Long
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For lngRow = 1 To lngLastRow
'step 1
Range("A1,C1,E1,G1,I1,K1").Select
Range("K1").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("P1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
'Step 2
Sheets("Sheet1").Select
Range("B1,D1,F1,H1,J1,L1").Select
Range("L1").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Import").Select
Range("Q1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
'Step 3
Range("O12:O18").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("N1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Next lngRow
End Sub
Please note that some cell references aboe are not precise but you get my point...
Also i would like to introduce some time delay in milliseconds before step 3.... any code reocommended ?
Can some gurus please suggest an efficient way or even a different piece of elegent code to do it. I am an infrequent user of excel vba macro and I am just taking up time to come up with it.
I have attached a sample spreadsheet with the input and output fields.
Thank you for your help! Please let me know ifyou have questions.
Bookmarks