Hi
First off this is an awesome resource and forum so thank you.
What I'm trying to do has 4 columns:
Column A: This has two data ranges placed in it, separated by a few blank lines.
Column B: I need the second range, which is also made up of worded hyperlinks (starting at A:30 to A: ?), to be duplicated here for a specified amount (I'll specify the amount because it continually changes, maybe a input box would work here?). So it'll be list of the same words repeated one below the other.
Column C: I need to concatenate the duplicated word list in Column B with the 1st range in Column A (Starting at A3:A?, usually there aren't that many maybe between 4 and 12 words but it will vary). The concatenation needs to start on the second word of the Column B list, see the example.
Column F: Will have hyperlinks aligned on the same row it's corresponding new word in Column B. Being able to have a macro that separates the 2nd range word links in Column B to coincide with the first new word of the same name would be helpful. Also being able to remove the hyperlink from the 2nd data range in Column A afterwords would also be great but not essential as I can do this manually.
Here's an example of what it would look like:
Column A
Column B
Column C
Column F
Brown
Dog
http://www.animals.com/dog
Black
Dog
Dog Brown
Tan
Dog
Dog Black
White
Dog
Dog Tan
Brindle
Dog
Dog White
Dog
Dog Brindle
Cat
http://www.animals.com/dog
Cat
Cat Brown
Cat
Cat Black
Dog
Cat
Cat Tan
Cat
Cat
Cat White
Horse
Cat
Cat Brindle
Gerbil
Horse
http://www.animals.com/horse
Horse
Horse Brown
Horse
Horse Black
"
"
....And so on
I previously recorded an entire manual process which works, but I had to create individual macros for each number of duplicates I was making, for example 4 duplicates, 5 duplicates. I could change each individual range for a new duplicate number but it would be time consuming (takes just as long as doing it manually). I now have a macro which solves the Column B problem, but if anyone can help with either more efficient code or add ons that would be appreciated.
VB:
Sub ContextualItems()
Dim Repeats As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim RowCount
Dim r As Long
Repeats = 12
FirstRow = 30
LastRow = Range("A" & Rows.Count).End(xlUp).Row
RowCount = Repeats * (LastRow - FirstRow + 1)
Range("A30:A87").Copy Destination:=Range("B2").Resize(RowCount)
Columns("B:B").Select
ActiveWorkbook.Worksheets("content_theme_ideas_20110811_06").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("content_theme_ideas_20110811_06").Sort.SortFields. _
Add Key:=Range("B1"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("content_theme_ideas_20110811_06").Sort
.SetRange Range("B2:B697")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim rng As Range
Set rng = Sheet1.Range("A4:A14")
End Sub
If you like these VB formatting tags please consider sponsoring me in support of injured Royal Marines
I understand it may not very clear so please ask if you have an issue with my question (I'm a VBA noob! )
Thanks in advance.