Copy By Variable

Z

zyus

I want to copy based on value in a cell

ex A1 value $100
A2 value 5
i exp that i could run some function to copy $100 five times in cell
A3,A4,A5,A6 & A7.

I have about 300 columns with different types of values

Thanks
 
F

Faraz A. Qureshi

You could use the following macro by:
1. Right click on the sheet tab at the bottom;
2. Selecting View Code;
3. Copy paste the following code:

Sub Macrox()
Dim x As Integer
Dim y As Integer
y = 1
Selection.Copy
x = ActiveCell.Offset(1, 0).Value
ActiveCell.Offset(2, 0).Select
Do Until x = y
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
y = y + 1
Loop
Application.CutCopyMode = False
End Sub

4. Now, CLICK/ACTIVATE cell where the value to be copied & pasted is present
(forexample A1). The number of times the cell is to be pasted is the cell
below it (in this example A2)
5. Go back to the sheet;
6. Press Alt+F8;
8. Select Macrox to be run;
9. Use it on any other column.
 
R

RagDyer

You could enter this in A3:

=IF(A$2-ROWS($1:1)+1>0,A$1,"")

And copy down as needed.
 
Z

zyus

Tried but pop op compile & syntax error and item highlighted as per below

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
 
D

Dave Peterson

This is one logical line.

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

The space character followed by the underscore character means that it's
continued on the next physical line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top