I am attempting a conversion from excel of a massive character generator and am having issues with this macro. It does 2 different things:
- Opens a certain worksheet (Class Options) if class/classes are selected and formats the worksheet by only showing certain columns (the class/classes chosen). Otherwise, if no classes are selected, the worksheet should remain hidden.
- The 2nd If statement opens specific worksheets if the value in a particular cell is “true”. Calc converted this formulas in these cells to 1’s and 0’s instead of true/false, but simply correcting that doesn’t help. I understand that macros need to be rewritten in Libre.
If anyone has suggestions, I’ll be eternally grateful. Thanks. Here is the excel code:
Rem Attribute VBA_ModuleType=VBADocumentModule
Option VBASupport 1
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws1 As Worksheet, i, c, CL
'user picks a class each time they gain 1 level of experience, from drop downs in range below
If Not Intersect(Target, Range(“C4:C23”)) Is Nothing Then
Set ws1 = Sheets(“Class Options”)
'on the next line, change the .Address (keep the dollar signs) to the first entry cell
'this will auto-hide all of the columns
If Target.Address = “$C$4” Then ws1.Columns(“A:X”).EntireColumn.Hidden = True
'on the next line, adjust the range where the column headers are on the Sheet
Set c = ws1.Range(“B1:X1”).Find(Target.Value)
If Not c Is Nothing Then
CL = Split(c.Address, “$”)(1)
ws1.Columns(Chr(Asc(CL) - 1) & “:” & Chr(Asc(CL) + 1)).EntireColumn.Hidden = False
End If
End If
If Range("S5").Value = True Then
Sheets("Spells Prepared or Known").Visible = xlSheetVisible
Sheets("Character Sheet 3 - Spells").Visible = xlSheetVisible
Else
Sheets("Spells Prepared or Known").Visible = xlSheetHidden
Sheets("Character Sheet 3 - Spells").Visible = xlSheetHidden
End If
If Range("S4").Value = True Then
Sheets("Spellbook").Visible = xlSheetVisible
Else
Sheets("Spellbook").Visible = xlSheetHidden
End If
If Range("S6").Value = True Then
Sheets("Feat Options").Visible = xlSheetVisible
Else
Sheets("Feat Options").Visible = xlSheetHidden
End If
If Range("S7").Value = True Then
Sheets("Druid Wildshape Form Stats").Visible = xlSheetVisible
Else
Sheets("Druid Wildshape Form Stats").Visible = xlSheetHidden
End If
If Range("S8").Value = True Then
Sheets("Ranger Animal Companion Stats").Visible = xlSheetVisible
Else
Sheets("Ranger Animal Companion Stats").Visible = xlSheetHidden
End If
End Sub