Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Chloe Brown   on Sep 21 In MS Office Category.

  
Question Answered By: Robin Hayes   on Sep 21

OK... from what I can tell,
it looks like you're wanting to
check a cell (K125) and see if it has
a value of (1) then, you're copying
17 rows of data from 65 columns (columns "B" thru "??").

(BTW, your "If (Range("K125") = 1) then" doesn't have
and End If)

what I don't understand is what you're doing
with it.
You're first pasting the VALUEs in D114-D130, but never
doing anything with it!

Then you're inserting the original formulas
into D132-D148 and shifting the columns to the right.

So, what you end up with, is cells D132-BD148
having the exact same formulas as cells B89-BA105.

Well, if you can figure that out,
I can help  you with the loop...
Provided you know what you're doing, I would use:

Since you said 65 columns, starting  with "B":
'-----------------------------------------------------
For I = 2 to 66
Range(cells(89,I),Cells(105,I)).Select
Selection.Copy
Range("D114").Select
Selection.PasteSpecial Paste:=xlPasteValues,_
Operation:=xlNone,Skipblanks:=False,_
Transpose:=false
if (Range("K125") = 1) then
Range(Cells(89,I),Cells(105,I).Select
Selection.Copy
Range("D132").Select
Selection.Insert Shift:=xlToRight
end if
Next I
'----------------------------------------------------
Now, the problem with this is, I have no idea
what you mean by:
"Where here the range  will be compared with a range
of my choice" ?? how are you going to compare a range?

"a definite range at "C114"" ??

From what I can tell, you have 65 columns of data in 17 rows.
"somehow" you have a list that identifies which rows to copy.
but I can't tell how.

Hopefully, this loop example will give you an idea
on how to automate it...

If you can help me understand what you need, maybe I can
be more helpful.

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to Simplyfied and make the code works. Or get search suggestion and latest updates.


Tagged: