The VBA Code Needed for multiple paste cells

crystian

New Member
Joined
Nov 13, 2013
Messages
3
Hello to You All,
I want to write a code in VBA from Excel (part of the Office 2010 version). I will make a short describe to my problem:
- In a column (eg: column "C") I have a different values (eg 30 values);
- I want to multiple select (eg. from 5 to 5 values of cells corresponding) and multiple paste It to column (eg "D" column). The results should be same as selected values from "C" column and very important paste from 5 to 5 rows (in same column "D"), as in example:
A B C D
1 2.5 2.5
2 3.5
3 1.2
4 3.5
5 0.9 0.9
6 1.78
7 2.6
and so on until row no. 30.
Can You advice me what are the appropriate VBA code for solve my issue?
Thank You in advance.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
see if this code works for you.

Rich (BB code):
Sub crystian()
'for http://www.mrexcel.com/forum/excel-...cations-code-needed-multiple-paste-cells.html
Selection.Offset(0, 3).Value = Selection.Value
End Sub

The code basically says that whatever you have selected, move 0 rows down (0) and 3 to the right (3). That value equals what you have selected.

If you want it to go to a different column, change the offset (0, value) to a different one depending on where you want it to go.

Hope that helps.
 
Upvote 0
To dermie_72,
Well, Your code work fine when I select eg.B2:B10. Every value on the cells B2:B10 are moved to right column. Problem occurs when I try to select eg. B2,B4,B7 (the cells are different values) and so on, in that situation the code move to the right column only first value selected, in that case the B2 value and multiply to next cells C4, C7- same value (eg number 3).
Thank You anyway for Yours answer.

see if this code works for you.

Rich (BB code):
Sub crystian()
'for http://www.mrexcel.com/forum/excel-...cations-code-needed-multiple-paste-cells.html
Selection.Offset(0, 3).Value = Selection.Value
End Sub

The code basically says that whatever you have selected, move 0 rows down (0) and 3 to the right (3). That value equals what you have selected.

If you want it to go to a different column, change the offset (0, value) to a different one depending on where you want it to go.

Hope that helps.
 
Upvote 0
Hi Crystian,

Sorry about that, I thought I checked this, but when I double checked I received the same result.
Try this code instead. I triple checked this one, and it seems to work fine.
Let me know how you go either way.
Rich (BB code):
Sub crystian()
'for http://www.mrexcel.com/forum/excel-...cations-code-needed-multiple-paste-cells.html
Dim Y As Integer
Y = Selection.Column
LR = Cells(Rows.Count, Y).End(xlUp).Row
Selection.Font.Bold = True
For X = 1 To LR
    If Cells(X, Y).Font.Bold = True Then
        Cells(X, Y).Offset(0, 3).Value = Cells(X, Y).Value
        Else
    End If
Next X
Selection.Font.Bold = False
End Sub
 
Upvote 0
Hello dermie_72,
I have tested Your final code and them work impeccable. Thank You for Your time and for availability to help me solve that issue. Now thanks to You I am ready to work.
All best wishes and keep on touch to Mr. excel Forum.
Kind regards,
Crystian.
 
Upvote 0

Forum statistics

Threads
1,216,102
Messages
6,128,846
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top