selection change issue

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
It deletes Range H5:K16 to the left. If that needs changing, change it or let us know what it needs to be.
Code:
Sub Maybe()
Application.ScreenUpdating = False
Select Case Range("E3").Value

Case 1
Range("H5:K16").Delete Shift:=xlToLeft
Range("H5").Value = "Pocket 1"
With Range("H5:H16")
    .Borders(xlEdgeLeft).LineStyle = xlContinuous
    .Borders(xlEdgeRight).LineStyle = xlContinuous
    .Borders(xlEdgeTop).LineStyle = xlContinuous
    .Borders(xlEdgeBottom).LineStyle = xlContinuous
    .Borders(xlInsideHorizontal).LineStyle = xlContinuous
End With

Case 2
Range("H5:K16").Delete Shift:=xlToLeft
Range("H5:I5").Value = Array("Pocket 1", "Pocket 2")
With Range("H5:I16")
    .Borders(xlEdgeLeft).LineStyle = xlContinuous
    .Borders(xlEdgeRight).LineStyle = xlContinuous
    .Borders(xlEdgeTop).LineStyle = xlContinuous
    .Borders(xlEdgeBottom).LineStyle = xlContinuous
    .Borders(xlInsideHorizontal).LineStyle = xlContinuous
    .Borders(xlInsideVertical).LineStyle = xlContinuous
End With

Case 3
Range("H5:K16").Delete Shift:=xlToLeft
Range("H5:J5").Value = Array("Pocket 1", "Pocket 2", "Pocket 3")
With Range("H5:J16")
    .Borders(xlEdgeLeft).LineStyle = xlContinuous
    .Borders(xlEdgeRight).LineStyle = xlContinuous
    .Borders(xlEdgeTop).LineStyle = xlContinuous
    .Borders(xlEdgeBottom).LineStyle = xlContinuous
    .Borders(xlInsideHorizontal).LineStyle = xlContinuous
    .Borders(xlInsideVertical).LineStyle = xlContinuous
End With

Case 4
Range("H5:K16").Delete Shift:=xlToLeft
Range("H5:K5").Value = Array("Pocket 1", "Pocket 2", "Pocket 3", "Pocket 4")
With Range("H5:K16")
    .Borders(xlEdgeLeft).LineStyle = xlContinuous
    .Borders(xlEdgeRight).LineStyle = xlContinuous
    .Borders(xlEdgeTop).LineStyle = xlContinuous
    .Borders(xlEdgeBottom).LineStyle = xlContinuous
    .Borders(xlInsideHorizontal).LineStyle = xlContinuous
    .Borders(xlInsideVertical).LineStyle = xlContinuous
End With
End Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0
If deleting is not an option.
Under every line where it has Case (1, 2, 3, 4), replace this line
Code:
Range("H5:K16").Delete Shift:=xlToLeft
With this
Code:
With Range("H5:K16")
    .ClearContents
    .Borders.LineStyle = xlNone
End With
 
Upvote 0
its not triggering if i run your code its simply coming whole format which i have shown in picture

can u make it for event trigger..i want to add it in event change

based on value E3

format need to tigger

E3=1

H5:H16 format should be visible
 
Upvote 0
Maybe, after 239 posts, you could find out how to do that by searching the net or this site.
If you really can't find anything on the net, let us know.

Oh well, it is the holiday season after all.
Put this in the sheet module.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$E$3" Then
        Call Maybe_B
    End If
End Sub

Have a Happy New Year.
 
Upvote 0
It deletes Range H5:K16 to the left. If that needs changing, change it or let us know what it needs to be.
This is basically your code with the Select Case removed...
Code:
[table="width: 500"]
[tr]
	[td]Sub Maybe2()
  Dim Target As Range
  Set Target = Range("E3")
  With Range("H5:K16")
    .ClearContents
    .Borders(xlEdgeLeft).LineStyle = xlNone
    .Borders(xlEdgeTop).LineStyle = xlNone
    .Borders(xlEdgeBottom).LineStyle = xlNone
    .Borders(xlEdgeRight).LineStyle = xlNone
    .Borders(xlInsideVertical).LineStyle = xlNone
    .Borders(xlInsideHorizontal).LineStyle = xlNone
  End With
  If Target.Value Like "[1-4]" Then
    With Range("H5:H16").Resize(, Target.Value)
      .Rows(1) = Split(Left("Pocket1 Pocket2 Pocket3 Pocket4", 8 * Target.Value))
      .Borders(xlEdgeLeft).LineStyle = xlContinuous
      .Borders(xlEdgeRight).LineStyle = xlContinuous
      .Borders(xlEdgeTop).LineStyle = xlContinuous
      .Borders(xlEdgeBottom).LineStyle = xlContinuous
      .Borders(xlInsideHorizontal).LineStyle = xlContinuous
      .Borders(xlInsideVertical).LineStyle = xlContinuous
    End With
  End If
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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
Back
Top