I know there's a limit of 24 line continuations, but is there any way to fix the following? Im basically using this code to go through each sheet and only keep the column headers listed within the list. So if I break it apart into two Subs, everything in the 2nd sub will be removed when the 1st sub is ran. I need to have a way to keep all of the specified columns within a single sub. I read something that said you could use the "+" to consolidate the lines but I haven't been able to figure that out.
This is the current code that is obliviously too long:
I did the following, but this doesn't work like i need it to.
This is the current code that is obliviously too long:
VBA Code:
Sub newcolumnremove()
Worksheets("vInfo").Activate
Range("A1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "vCenter Server" _
Or ActiveCell.Value = "vCenter Version" _
Or ActiveCell.Value = "VM" _
Or ActiveCell.Value = "Powerstate" _
Or ActiveCell.Value = "DNS Name" _
Or ActiveCell.Value = "CPUs" _
Or ActiveCell.Value = "Memory" _
Or ActiveCell.Value = "NICs" _
Or ActiveCell.Value = "Latency Sensitivity" _
Or ActiveCell.Value = "Primary IP Address" _
Or ActiveCell.Value = "Network #1" _
Or ActiveCell.Value = "Network #2" _
Or ActiveCell.Value = "Network #3" _
Or ActiveCell.Value = "Network #4" _
Or ActiveCell.Value = "Num Monitors" _
Or ActiveCell.Value = "Video Ram KB" _
Or ActiveCell.Value = "Resource pool" _
Or ActiveCell.Value = "Folder" _
Or ActiveCell.Value = "vApp" _
Or ActiveCell.Value = "FT State" _
Or ActiveCell.Value = "Provisioned (GB)" _
Or ActiveCell.Value = "Used (GB)" _
Or ActiveCell.Value = "Unshared (GB)" _
Or ActiveCell.Value = "HA Restart Priority" _
Or ActiveCell.Value = "HA VM Monitoring" _
Or ActiveCell.Value = "Cluster rule(s)" _
Or ActiveCell.Value = "Cluster rule name(s)" _
Or ActiveCell.Value = "Firmware" _
Or ActiveCell.Value = "HW version" _
Or ActiveCell.Value = "Path" _
Or ActiveCell.Value = "Log directory" _
Or ActiveCell.Value = "Snapshot directory" _
Or ActiveCell.Value = "Suspend directory" _
Or ActiveCell.Value = "Annotation" _
Or ActiveCell.Value = "Description" _
Or ActiveCell.Value = "Environment" _
Or ActiveCell.Value = "Datacenter" _
Or ActiveCell.Value = "Cluster" _
Or ActiveCell.Value = "Host" _
Or ActiveCell.Value = "VM ID"_
Or ActiveCell.Value = "HA Isolation Response" Then
ActiveCell.Offset(0, 1).Select
Else
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
Selection.End(xlUp).Select
End If
Loop
I did the following, but this doesn't work like i need it to.
VBA Code:
Sub one()
Worksheets("vInfo").Activate
Range("A1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "vCenter Server" _
Or ActiveCell.Value = "vCenter Version" _
Or ActiveCell.Value = "VM" _
Or ActiveCell.Value = "Powerstate" _
Or ActiveCell.Value = "DNS Name" _
Or ActiveCell.Value = "CPUs" _
Or ActiveCell.Value = "Memory" _
Or ActiveCell.Value = "NICs" _
Or ActiveCell.Value = "Latency Sensitivity" _
Or ActiveCell.Value = "Primary IP Address" _
Or ActiveCell.Value = "Network #1" _
Or ActiveCell.Value = "Network #2" _
Or ActiveCell.Value = "Network #3" _
Or ActiveCell.Value = "Network #4" _
Or ActiveCell.Value = "Num Monitors" _
Or ActiveCell.Value = "Video Ram KB" _
Or ActiveCell.Value = "Resource pool" _
Or ActiveCell.Value = "Folder" _
Or ActiveCell.Value = "vApp" _
Or ActiveCell.Value = "FT State" _
Or ActiveCell.Value = "Provisioned (GB)" _
Or ActiveCell.Value = "Used (GB)" _
Or ActiveCell.Value = "Unshared (GB)" Then
ActiveCell.Offset(0, 1).Select
Else
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
Selection.End(xlUp).Select
End If
Loop
End Sub
Sub two()
Worksheets("vInfo").Activate
Range("A1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "HA Restart Priority" _
Or ActiveCell.Value = "HA VM Monitoring" _
Or ActiveCell.Value = "Cluster rule(s)" _
Or ActiveCell.Value = "Cluster rule name(s)" _
Or ActiveCell.Value = "Firmware" _
Or ActiveCell.Value = "HW version" _
Or ActiveCell.Value = "Path" _
Or ActiveCell.Value = "Log directory" _
Or ActiveCell.Value = "Snapshot directory" _
Or ActiveCell.Value = "Suspend directory" _
Or ActiveCell.Value = "Annotation" _
Or ActiveCell.Value = "Description" _
Or ActiveCell.Value = "Environment" _
Or ActiveCell.Value = "Datacenter" _
Or ActiveCell.Value = "Cluster" _
Or ActiveCell.Value = "Host" _
Or ActiveCell.Value = "VM ID" _
Or ActiveCell.Value = "HA Isolation Response" Then
ActiveCell.Offset(0, 1).Select
Else
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
Selection.End(xlUp).Select
End If
Loop
End Sub