Copy specific cells at random rows

JorgenKjer

Board Regular
Joined
Aug 1, 2016
Messages
65
Office Version
  1. 2013
Platform
  1. Windows
Is there anyone who can help with a code?

I want to select a random cell in column Aand in that row copy the values ​​in columns A: C and E: G and I: J

In this example it is row 4 but it might aswell be row 10 so the code should take into account random rows depending onthe active cell in column A.

Hope this makes sense

Greetings Jorgen

5nY7vknJv6AAAAAASUVORK5CYII=



 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I've tried to create a code that can execute what I need, but I think it must be possibleto make it smarter
Does anyonehave a suggestion?

Sub offset_2()

Range (ActiveCell.offset(0, 0), ActiveCell.offset(0, 2)).Select
Selection.Copy
Selection.offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

Range(ActiveCell.offset(-3, 4), ActiveCell.offset(-3, 6)).Select
Selection.Copy
Selection.offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

Range(ActiveCell.offset(-3, 4), ActiveCell.offset(-3, 5)).Select
Selection.Copy
Selection.offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues


End Sub
 
Last edited:
Upvote 0
How about
Code:
Sub JorgenKjer()
   With ActiveCell
      .Offset(3).Resize(, 3).Value = .Resize(, 3).Value
      .Offset(3, 4).Resize(, 3).Value = .Offset(, 4).Resize(, 3).Value
      .Offset(3, 8).Resize(, 2).Value = .Offset(, 8).Resize(, 2).Value
   End With
End Sub
 
Upvote 0
Hi Fluff
I am sure Imust have misunderstood how to use your code. However, I have tried to add somelines to the code and only the first active cell is copied. What am I doingwrong?
Greeting Jorgen

Sub JorgenKjer()
With ActiveCell
.offset(3).Resize(, 3).Value = .Resize(, 3).Value
.offset(3, 4).Resize(, 3).Value = .offset(, 4).Resize(, 3).Value
.offset(3, 8).Resize(, 2).Value = .offset(, 8).Resize(, 2).Value
End With

Selection.Copy
Selection.offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

End Sub



 
Upvote 0
You don't need to add anything to the code.
Simply select a cell in col A & run the code "as-is"
 
Upvote 0
Hi Fluff
You are right
Once again,you have come to my rescue
Thank you
Greeting Jorgen
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,530
Members
452,651
Latest member
wordsearch

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