BBcode conversion

vass

New Member
Joined
Oct 13, 2006
Messages
2
I am working on an Excel spreadsheet to output to simple BBcode. The codes available are limited, and right now I am only accounting for
, [td], and . I am new to this and want to add on to the macro to account for basic colors (in this format: ), bold and italics . It would also be great to have a way to have the output automatically copied to the clipboard. I'd appreciate any guidance/suggestions you might have.

This is the macro I have so far:

Code:
Option Explicit
Sub MyExport()
  Dim RowStart As Integer
  Dim ColStart As Integer
  Dim ColCount As Integer
  Dim RowCount As Integer
  Dim RowEnd As Integer
  Dim ColEnd As Integer
  Dim ctrRow As Integer
  Dim ctrCol As Integer
  Dim TableName As String
  Dim CellString As String

  'Get Selection Location and Size
  RowStart = Selection.Row
  ColStart = Selection.Column
  ColCount = Selection.Columns.Count
  RowCount = Selection.Rows.Count
  RowEnd = RowStart + RowCount - 1
  ColEnd = ColStart + ColCount - 1
  
  'Get Table Name
  TableName = Sheet1.TextBoxTableName.Text
  
  'Start Table
  Sheet1.TextBoxOutput.Text = TableName + "[table=" + Sheet1.TextBoxTableName.Text + "]"
  
  'Make Table Cells
  For ctrRow = RowStart To RowEnd
    Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[tr]"
    For ctrCol = ColStart To ColEnd
      CellString = Sheet1.Cells(ctrRow, ctrCol).Text
      Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[td]" + CellString + "[/td]"
    Next ctrCol
    Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[/tr]"
  Next ctrRow
  
  'Close Table
  Sheet1.TextBoxOutput.Text = Sheet1.TextBoxOutput.Text + "[/table]"

End Sub

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,136,272
Messages
5,674,753
Members
419,525
Latest member
helensesc

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
Top