ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy By Variable (https://www.excelbanter.com/excel-discussion-misc-queries/233401-copy-variable.html)

zyus

Copy By Variable
 
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





Faraz A. Qureshi

Copy By Variable
 
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.

--
Do check "Yes" if this post is helpful,
Best Regards,

Faraz


"zyus" wrote:

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





RagDyeR

Copy By Variable
 
You could enter this in A3:

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

And copy down as needed.
--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------

"zyus" wrote in message
...
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







zyus

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

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


"Faraz A. Qureshi" wrote:

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.

--
Do check "Yes" if this post is helpful,
Best Regards,

Faraz


"zyus" wrote:

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





Dave Peterson

Copy By Variable
 
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.

zyus wrote:

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

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

"Faraz A. Qureshi" wrote:

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.

--
Do check "Yes" if this post is helpful,
Best Regards,

Faraz


"zyus" wrote:

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





--

Dave Peterson


All times are GMT +1. The time now is 02:43 PM.

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