Forum Discussion

SamFares's avatar
SamFares
Brass Contributor
Nov 14, 2019
Solved

Macro to delete certain cells in several columns depending cell value in a different cell

Hello All, In the attached Excel sheet, "Input Continuous-Span Beam" tab, I'd like a macro to do the following when:  1. Cell B10=2, to delete the cells highlighted in yellow for Span#3,4&5 only. ...
  • Riny_van_Eekelen's avatar
    Nov 15, 2019

     

    SamFares

    This code will CLEAR the ranges depending on 2, 3 or 4. Deleting them would screw your entire sheet, I guess.

    Sub ClearSpan()
    
    Dim NoSpansN As Integer
    
    NoSpansN = Range("B10").Value
    
    Select Case NoSpansN
    
        Case 2
            Range("J17:U58").Select
            Selection.Clear
        
        Case 3
            Range("N17:U58").Select
            Selection.Clear
        
        Case 4
            Range("R17:U58").Select
            Selection.Clear
        
    End Select
    
        Range("B10").Select
        
    End Sub

     The next code will clear the contents of the yellow cells in the LE and RE Cantilever sections:

    Sub DeleteLE_RE()
    
        Range("D60:D65,G64,H60,Q60:Q65,T64,U60").Select
        Selection.ClearContents
        
    End Sub

    If this is not what you have in mind, please clarify your needs.

     

Resources