Display difference specific range of cell in the same worksheet by clicking button in VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-1870312%22%20slang%3D%22en-US%22%3EDisplay%20difference%20specific%20range%20of%20cell%20in%20the%20same%20worksheet%20by%20clicking%20button%20in%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1870312%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20There.%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20new%20here.%20Just%20learning%20VBA%20to%20create%20some%20records%20for%20my%20own%20personal%20use.%20Can%20anyone%20share%20with%20me%20the%20codes%20on%20how%20to%20display%20a%20specific%20range%20of%20cells%20within%20the%20same%20worksheet%3F%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20example%2C%20if%20I%20click%20button%20A%2C%20the%20coding%20will%20lead%20me%20and%20display%20only%20the%20range%20of%20cells%20from%20A1%3AO26%20and%20if%20I%20click%20button%20B%2C%20the%20coding%20will%20allow%20me%20to%20display%20only%20the%20range%20of%20P1%3AAD26.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20guys%3F%20Thanks%20in%20advance%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1870312%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1871304%22%20slang%3D%22de-DE%22%3ESubject%3A%20Display%20difference%20specific%20range%20of%20cell%20in%20the%20same%20worksheet%20by%20clicking%20button%20in%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1871304%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F863511%22%20target%3D%22_blank%22%3E%40Tariq_Rahmalan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EHere's%20an%20example%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EOption%20Explicit%0A%0APrivate%20Sub%20CommandButton1_Click()%0ADim%20wks%20As%20Worksheet%0A%20%20%20%20Set%20wks%20%3D%20ThisWorkbook.Worksheets(%22Tabelle1%22)%0A%20%20%20%20Application.Goto%20wks.Range(%22A1%3AO26%22)%2C%20True%0AEnd%20Sub%0A%0A%20%0APrivate%20Sub%20CommandButton2_Click()%0ADim%20wks%20As%20Worksheet%0A%20%20%20%20Set%20wks%20%3D%20ThisWorkbook.Worksheets(%22Tabelle1%22)%0A%20%20%20%20Application.Goto%20wks.Range(%22P1%3AAD26%22)%2C%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20be%20happy%20to%20know%20if%20I%20could%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E*%20Kindly%20Mark%20and%20Vote%20this%20reply%20if%20it%20helps%20please%2C%20as%20it%20will%20be%20beneficial%20to%20more%20community%20members%20reading%20here.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi There.

I'm new here. Just learning VBA to create some records for my own personal use. Can anyone share with me the codes on how to display a specific range of cells within the same worksheet?

For example, if I click button A, the coding will lead me and display only the range of cells from A1:O26 and if I click button B, the coding will allow me to display only the range of P1:AD26.

 

Any ideas guys? Thanks in advance

1 Reply
Highlighted

@Tariq_Rahmalan 

 

Here's an example

 

 

Option Explicit

Private Sub CommandButton1_Click()
Dim wks As Worksheet
    Set wks = ThisWorkbook.Worksheets("Tabelle1")
    Application.Goto wks.Range("A1:O26"), True
End Sub

 
Private Sub CommandButton2_Click()
Dim wks As Worksheet
    Set wks = ThisWorkbook.Worksheets("Tabelle1")
    Application.Goto wks.Range("P1:AD26"), True
End Sub

 

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

 

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.