+ Reply to Thread
Results 1 to 4 of 4

Selection of x*x in matrix

  1. #1
    Registered User
    Join Date
    03-04-2017
    Location
    norway
    MS-Off Ver
    2016
    Posts
    41

    Selection of x*x in matrix

    Hello! I am hoping for some more help. I want to select a square of x*x where x is variable(FIN as I did here) and calculated in 2 first lines in the code below. Selecting x values in single column isn`t a problem, but I would like to select whole square(X*X starting at B2). I have a value calculated in another cell(coded as countif). Total selected cells should be the power of that value. If 5, total cells selected should be 25 etc(matrix). It must be accurate, because the next step will be to use the =mmult function(creating matrix), which I have ready to use from the selection:

    Sub selection()
    Workbooks("Database.xlsm").Worksheets("Sheet1").Activate
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "=(COUNTIF(R[1]C[-1]:R[1048575]C[-1],""*""))"

    Dim FIN As Long
    Workbooks("Database.xlsm").Worksheets("Matrix").Activate
    Worksheets("Matrix").Activate
    FIN = Worksheets("Sheet1").Cells("1", "B").Value
    Dim StartCellLtR As String
    Dim StartCellNuM As Integer
    Dim EndCellLtR As String
    Dim EndCellNuM As Integer
    Dim TheRangE As String
    Dim perfect As String

    StartCellLtR = "B"
    StartCellNuM = 2
    EndCellLtR = "B"
    EndCellNuM = FIN + 1

    TheRangE = StartCellLtR & Trim(StartCellNuM) & ":" & EndCellLtR & Trim(EndCellNuM)
    Range(TheRangE).Select

    End Sub
    Really appreciate any help. The function works properly except selecting the whole square(it only selects "x" value down in the column).
    Last edited by olli.excel; 03-11-2017 at 04:27 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Selection of x*x in matrix

    If you want to refer to an X by X range with the top left corner at rngSomeRange, then you can use the Resize property.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    03-04-2017
    Location
    norway
    MS-Off Ver
    2016
    Posts
    41

    Re: Selection of x*x in matrix

    Thank you. The selection starts in B2 and need to select x*x square. Would that work without messagebox?(it will be in middle of the master code)?

  4. #4
    Registered User
    Join Date
    03-04-2017
    Location
    norway
    MS-Off Ver
    2016
    Posts
    41

    Re: Selection of x*x in matrix

    Found a lot simplier code in another forum. Thank you for helping!

    Dim size As Integer
    size = Worksheets("Sheet1").Cells(1, 2).Value
    Workbooks("Database.xlsm").Worksheets("Matrix").Activate
    Range("B2").Activate
    Range(Cells(2, 2), Cells(1 + size, 1 + size)).Select

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 06-21-2015, 09:40 PM
  2. Replies: 2
    Last Post: 11-05-2014, 03:41 AM
  3. [SOLVED] find data from matrix and show me in another sheet base on my selection and relative data
    By pedjvak in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-16-2014, 05:42 AM
  4. Replies: 2
    Last Post: 02-11-2014, 05:05 AM
  5. User Form Matrix Cell Selection - Does it exist?
    By FMontgomery in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2013, 05:41 PM
  6. cell selection and data entry in binary matrix
    By Nick00004 in forum Excel General
    Replies: 17
    Last Post: 07-09-2013, 12:19 PM
  7. Using a transition matrix as input to a cummulative matrix
    By Walter12 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 04:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1