Hello!
I have some code that combines text together. Because of the number of characters I have to export the text to word. I have two issues:
1) The formatting between the text is not correct. I want to apply spacing between my variables and then a page break between each new row.
2) I am really struggling to export to word and autofit the contents.
Here is my code:
I've attached a screenshot of what it looks like.
Please can someone help me with the formatting and with exporting to word?
Thanks!
I have some code that combines text together. Because of the number of characters I have to export the text to word. I have two issues:
1) The formatting between the text is not correct. I want to apply spacing between my variables and then a page break between each new row.
2) I am really struggling to export to word and autofit the contents.
Here is my code:
VBA Code:
Sub inbrief()
Dim Cash As Range
Dim Title, activity, Description As String
Dim cell As Range
Dim CurrentRow, LastRow As Integer
Application.ScreenUpdating = False
CurrentRow = 3
'Clear sheet and filters
Sheets("In Briefs").Activate
Sheets("In Briefs").Range("$A$2:$H$1000").AutoFilter Field:=3
Sheets("In Briefs").Range("A3:H1000").ClearContents
'Copy SEDOLs from portfolio tab and bring in in briefs
Sheets("Portfolio").Range("A8:A100").Copy
Sheets("In Briefs").Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues
'Remove all the blank rows
LastRow = ActiveSheet.UsedRange.Rows.Count
Range("A3:A" & LastRow).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
'Copy the vlookup formulas to import the paras
Range("B1:D1").Copy
Range("B3:D" & LastRow).PasteSpecial xlPasteFormulas
'Join the header, activity and inbrief together and apply formatting
For Each cell In Range("F3:F" & LastRow)
If Range("C" & CurrentRow) <> "" Then
With Application
Title = Range("B" & CurrentRow).value
Description = Range("C" & CurrentRow).value & Chr(13)
activity = Range("D" & CurrentRow).value
End With
cell.value = Title & activity & Description
With cell
.Characters(1, Len(Title)).Font.Color = RGB(0, 89, 85)
.Characters(1, Len(Title)).Font.Size = 18
.Characters(Len(Title) + 1, Len(activity)).Font.Size = 11
.Characters(Len(Title) + 1, Len(activity)).Font.Color = vbBlack
.Characters(Len(Title) + Len(activity) + 1, Len(Description)).Font.Size = 11
.Characters(Len(Title) + Len(activity) + 1, Len(Description)).Font.Color = vbBlack
End With
End If
CurrentRow = CurrentRow + 1
Next
'Filter out any securities that have no data
With Range("$A$3:$H$" & LastRow)
.AutoFilter Field:=3, Criteria1:="="
.Offset(1).EntireRow.Delete
.AutoFilter
End With
Application.ScreenUpdating = True
End Sub
I've attached a screenshot of what it looks like.
Please can someone help me with the formatting and with exporting to word?
Thanks!