Hi,
I'm basically trying to copy x amount (number from cell) of names and pasting into a column named "Prelim" then the remaining names in the "1st Round" column. I'm also struggling with getting the numbers in column J. I have attached a test file as an example. Any help much appreciated.
Copying X amount of names from list and enter in another column
- How How
- Thread is marked as Resolved.
-
-
Re: Copying X amount of names from list and enter in another column
Hi
Paste the code below into the module named Test in the VB editor & have a play. I think it's what you're after
CheersCode
Display MoreOption Explicit Sub CopyOver() Dim Ws1 As Worksheet Dim rPrelims As Range, r1stRound As Range, jColCell As Range Dim Ws1Lrow As Long Dim strCell As String Set Ws1 = ThisWorkbook.Sheets(1) Set rPrelims = Ws1.Range("B6") Set r1stRound = Ws1.Range("B8") ' Find last used row number on Column D Sheet 1 Ws1Lrow = Ws1.Columns(4).Find(What:="*", LookIn:=xlValues, _ lookat:=xlPart, SearchOrder:=xlByRows, searchdirection:=xlPrevious, _ MatchCase:=False, searchformat:=False).Row ' B6 & B8 are not empty If Not IsEmpty(rPrelims) And Not IsEmpty(r1stRound) Then ' Copy the number of players in Prelim cell to column H Ws1.Range(Ws1.Cells(3, 4), Ws1.Cells(rPrelims.Value + 2, 4)).Copy Ws1.Range("H3") ' Copy the remainder of players to column K Ws1.Range(Ws1.Cells(rPrelims.Value + 3, 4), Ws1.Cells(Ws1Lrow, 4)).Copy Ws1.Cells(rPrelims.Value + 3, 11) ' Set the cell in column J which will hold the player number after the last one in column G Set jColCell = Ws1.Cells(rPrelims.Value + 3, 10) ' Get the non absolute address of the cell strCell = jColCell.Address(False, False) ' Put the place +1 of the last player in column G jColCell = Ws1.Cells(rPrelims.Value + 2, 7) + 1 ' Put formula in the rest of the range in column J Ws1.Range(Ws1.Cells(rPrelims.Value + 4, 10), Ws1.Cells(Ws1Lrow, 10)).Formula = "=(" & strCell & ")+1" ' Equiv =J3+1 End If Exit Sub End Sub
-
Re: Copying X amount of names from list and enter in another column
Wow....... Just tested it....... That is exactly what I needed, I had started using Vlookup formulas etc but this is much better. I should be able to use this in other applications to. Thank You :thumbcoo:
-
Re: Copying X amount of names from list and enter in another column
Jolly good
-
Re: Copying X amount of names from list and enter in another column
Ah, just found a hiccup...... In B2 determines the comp sheet I would use in the example 32.... If the player number is over 29 the col J is wrong as in the example below.......... everything else is fine... Easy fix?
[ATTACH=CONFIG]68760[/ATTACH]
-
-
Re: Copying X amount of names from list and enter in another column
I had a "Play" & using the case function I used 3 different cases,
1. For full sheet of players (eg 32), removed last line of code
2. For full <1 (eg sheet 32, 32 players), removed +1 from last line of code
3 for the rest.
Probably a bit messy but it works!! Thanks again
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!