Found this to copy data and populate new sheet. header works good
looking for a script to take 3 columns and inject cell value to a 5 column table. i have commented out the parts im troubled with.
Source is one sheet "MSDS" this code scans all sheets (not necessary) Column A is location, Column B is LinkName, Column C is Path. any ideas?
Sub MoveDataToHtmlSheet()
Dim firstrow As Integer
Dim lastrow As Long
Dim dest As Worksheet
Dim sht As Worksheet
Dim destcell As Range
firstrow = 2
'Insert new sheet as destination for data
Set dest = Sheets.Add
dest.Name = "html"
'Set range for copies to go to leaving a row for a header
Set destcell = dest.Range("A12")
With dest
.Range("A1").FormulaR1C1 = "<HTML>"
.Range("A2").FormulaR1C1 = "<head>"
.Range("A3").FormulaR1C1 = "<title>"
'A4 copy from source in Column "A"
.Range("A5").FormulaR1C1 = "</title>"
.Range("A6").FormulaR1C1 = "</head>"
.Range("A7").FormulaR1C1 = "<body>"
.Range("A8").FormulaR1C1 = "<H1>"
'A9 copy from source sheet in Column A
.Range("A10").FormulaR1C1 = "</H1>"
.Range("A11").FormulaR1C1 = "<table>"
End With
For Each sht In Sheets
If sht.Name <> dest.Name Then
'find bottom cell in col A
lastrow = sht.Range("A" & Rows.Count).End(xlUp).Row
'copy data range to destcell
sht.Rows(firstrow & ":" & lastrow).Copy Destination:=destcell
'set new position of destcell
Set destcell = destcell.Offset(lastrow - firstrow, 0)
' trying to make 3 columns fill 5 columns combined with html tags
' then concantinate and copy values to destination sheet - like this
' dest.Range("A" & nextRowD).FormulaR1C1 = "<tr><td><a href="""
' .Range("C" & Cells).Copy
' dest.Range("B" & nextRowD).PasteSpecial Paste:=xlPasteValues
' dest.Range("C" & nextRowD).FormulaR1C1 = """ alt="""
' .Range("B" & Cells).Copy
' dest.Range("D" & nextRowD).PasteSpecial Paste:=xlPasteValues
' dest.Range("E" & nextRowD).FormulaR1C1 = """ >"
' .Range("B" & Cells).Copy
' dest.Range("F" & nextRowD).PasteSpecial Paste:=xlPasteValues
' dest.Range("G" & nextRowD).FormulaR1C1 = "</a></td></tr>"
End If
Next sht
' Sheets("HTML").Select
' Range("H1").Select
' ActiveCell.FormulaR1C1 = "=RC[-7]&RC[-6]&RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
' Range("H1").Select
' Selection.Copy
'Range("I1").Select
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
':=False, Transpose:=False
End Sub