Complicated if/then copy operation?

Closed
Spremo Posts 1 Registration date Friday June 26, 2015 Status Member Last seen June 26, 2015 - Jun 26, 2015 at 06:15 PM
 Seth - Jun 29, 2015 at 05:50 PM
if (column range; eg, A8:A42) has any value, then Copy a cell (formula; in C2) two columns to the right of every cell in that column (A) that has a value.

Complicated, I think.

Basically, I have a cell with a formula. In column A, I need to manually input some findings. Not every cell in Row A is going to have input. But, for the ones that do have input, I want it to copy a formula to a cell in the same row, but 2 columns to the right.

Any ideas?
I'm familiar with the RC stuff, and formulation, but not when it contains 3 parties and an if/then statement. Any help would be appreciated.
Thanks!

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jun 29, 2015 at 04:38 AM
in C8 the formula is

=IF(A8<>"",A8,"")

copy C8 down

if you want vba here is the macro

Sub test()
Dim r As Range, c As Range
Set r = Range("A8:A42")
For Each c In r
If c <> "" Then c.Copy c.Offset(0, 2)
Next c
End Sub
0
Thanks, but that code & formula doesn't reference the cell with the formula I want copied.
This is a three-part problem to try to get excel to search an area, (A8:A42), and if there's a value in any cell within that range, then copy the formula contained within cell C2 to the same row as the value, except two columns to the right.

In my range A8:A42, Only about 1 in 8 cells will have a value. I have a formula saved in cell C2 that I need to manually paste apply to Column C, for any rows that have a value in column A.

basically... cell C2 has a formula in it. The formula can't be put into cells in the range (A8:A42) that are blank, or it will screw up my totals at the bottom.

Lets say, within my range of A8:A42, only three cells have values: A12, A32, and A41. I'd then want the formula in cell C2 to be copied to C12, C32, and C41 -- and ONLY those cells.

Thanks for any help. I probably didn't articulate the idea very clearly.
0
This is all I got so far, and it keeps telling me Compile Error: "Next without For".



Sub MacroTestAutoFill()
'
' MacroTestAutoFill Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim r As Range, c As Range
Set r = Range("T10:T205")
For Each c In r
If c = "" Then
Range("T5").Copy
Range("").Select
ActiveCell.Paste
Next c
End If
End Sub
0