ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear data range, and copy static value. (https://www.excelbanter.com/excel-programming/348784-clear-data-range-copy-static-value.html)

[email protected]

Clear data range, and copy static value.
 
1. How do I clear out a range of data that starts at B4 and goes down
the column...how would I put this in a loop?

' Clear column B starting at B4 ....
.Range("b4:b" & .Cells(Rows.Count,
"B").End(xlUp).Row).ClearContents

2. How do I copy (paste special) a cell on a worksheet and run it
through a loop to populate the rest of some cells?
Example: I11 = vlookup....... -- but displays RW1111
I want to copy that to E9 and down the rest of the column to correspond
to some other data I have there, but I can't get it to copy the
RW1111...it keeps coming up with a zero due to the vlookup I
suppose....any help?


Toppers

Clear data range, and copy static value.
 
Hi,

1. This code clears a column (B) from B4 to the last row (the variable
Lastrow is the row number of the last row in the column) so no need to loop.

2. To copy the value (as opposed to the formula) use something like:

Range("I11").Copy
Range("E9").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

If you want to copy I11 to a range of cells then one way is:

Range("I11").copy
For r=1 to 10
Range("E" & r).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
next r

OR

Range("I11").copy
Range("E1:E10").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

HTH

" wrote:

1. How do I clear out a range of data that starts at B4 and goes down
the column...how would I put this in a loop?

' Clear column B starting at B4 ....
.Range("b4:b" & .Cells(Rows.Count,
"B").End(xlUp).Row).ClearContents

2. How do I copy (paste special) a cell on a worksheet and run it
through a loop to populate the rest of some cells?
Example: I11 = vlookup....... -- but displays RW1111
I want to copy that to E9 and down the rest of the column to correspond
to some other data I have there, but I can't get it to copy the
RW1111...it keeps coming up with a zero due to the vlookup I
suppose....any help?




All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com