Results 1 to 3 of 3

Repair a macro

Threaded View

  1. #1
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Repair a macro

    Good evening all and anyone.

    Part 1

    Attached is my file and on the "Master" page there is a a hidden code ( Shown below ) that "Sintek" created for me last week initially it was to create blocks of data on the " Master " sheet dependent on how rows of data was associated with the Call sign that was entered in cell " C1 " on the " Master " sheet it would create between 1 and 6 blocks of selected data ( NOT ALL CELLS are SELECTED ), however I have now learned that in some cases I could have up to 10 or more rows of data for that call sign.

    I have shrunk the panels down and adjusted the font accordingly , so if possible could the code the adjust number of panels up to 10, a sample of the call sign for VK2RAG data is below.

    
    Call	             Output	    Input	Call	      mNemonic	Location	Service Area	      Latitude	Longitude	      Maidenhead	S	ERP	HASL	T/O	Sp	Tone	Notes
    
    VK2RAG	53.7250	52.7250	VK2RAG	Someb	Somersby	Gosford-Wyong	      -33.360078	  151.291215	QG321klm21	               O	50	320	3	2EH	91.5	67	
    VK2RAG	146.7250	146.1250	VK2RAG	Someb	Somersby	Gosford	              -33.360078	  151.291215		               O	50	320	3	2EH	91.5		
    VK2RAG	 147.1250	147.7250	VK2RAG	Someb1	Somersby	Gosford WICEN	      -33.360078	  151.291215		               O	50	320	3	2EH	91.5		
    VK2RAG	438.0750	431.0750	VK2RAG	Someb	Somersby	Gosford - Wyong      -33.360078	  151.291215		               O	50	320	3	2EH	91.5	107	
    VK2RAG	 438.8000	431.8000	VK2RAG	Someb1	Somersby	Gosford - Wyong      -33.360078	  151.291215		               O	50	320	3	2EH	91.5		
    VK2RAG	 438.8750	431.8750	VK2RAG	Someb2	Somersby	Gosford - Wyong      -33.360078	  151.291215		               O	25	320	3	2EH	91.5		
    VK2RAG	 439.9500	434.9500	VK2RAG	Someb3	Somersby	Central Coast	      -33.360078	  151.291215		               O	-	313	3	2EH	91.5		
    VK2RAG	1273.4000	1293.4000	VK2RAG	Someb	Somersby	Gosford -  7/18	      -33.360078    151.291215		               T	-	320	-	2EH	-		
    VK2RAG	146.6375	146.0375	VK2RAG C	Someb	Somersby	Gosford (G)	      -33.360078	  151.291215		               O	25	320	4	2EH	-		
    VK2RAG	438.3250	432.9250	VK2RAG B	Someb1	Somersby	Gosford (G)	      -33.360078    151.291215		               O	25	320	4	2EH	-		
    VK2RAG	1273.4000	1293.4000	VK2RAG A	Someb2	Somersby	Gosford 6/15	      -33.360078	  151.291215		               P	10	320	4	2EH	-		
    VK2RAG	439.9500	434.9500	VK2RAG	Someb	Somersby	Central Coast	      -33.360078	  151.291215		               O	-	300	3	2EH	91.5	107
    Here is the Code that "Sintek" created to fill the blocks as required..


    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Arr, cell As Range, rng As Range, Template As Range, ws As String, nxt As Boolean
    Dim lr As Long, i As Long, Col As Long, Row As Long, xx As Long, nrs As Long
    Set Template = Sheet12.Range("A1:B11")
    If Not Intersect(Target, Range("C1")) Is Nothing Then
        Set rng = ActiveSheet.Range("C4:C14,F4:F14,I4:I14,L4:L14,C16:C26,F16:F26,I16:I26,L16:L26")
        ActiveSheet.Range("A4:A24").EntireRow.Delete
        Application.EnableEvents = False
        rng.ClearContents: ws = Left(Target, 3): Col = 3: Row = 4
        With Sheets(ws)
            lr = .Range("A" & Rows.Count).End(xlUp).Row
            .Cells(1).CurrentRegion.AutoFilter 4, Target & "*"
            nrs = .AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1
            If Not nrs = 0 Then
                Set rng = .Range("A2:A" & lr).SpecialCells(12)
                For Each cell In rng
                    Debug.Print cell.Address
                    Template.Copy ActiveSheet.Cells(Row, Col - 1)
                   Arr = Array(cell.Offset(, 1), cell.Offset(, 2), cell.Offset(, 5), cell.Offset(, 6), cell.Offset(, 11), _
                    cell.Offset(, 12), cell.Offset(, 13), cell.Offset(, 15), cell.Offset(, 7), cell.Offset(, 8), cell.Offset(, 9))
                    For xx = LBound(Arr) To UBound(Arr)
                        Sheet1.Cells(Row, Col) = Arr(xx): Row = Row + 1
                    Next xx
                    Col = Col + 3
                    If Col = 15 Then
                        Col = 3: Row = 16: nxt = True
                    ElseIf nxt = False Then
                        Row = 4
                    Else
                        Row = 16
                    End If
                Next cell
            End If
            .AutoFilterMode = False
        End With
        Application.EnableEvents = True
    End If
    End Sub

    If I have not made myself clear enough please advise.


    Peter
    Last edited by Potholes; 05-20-2019 at 10:47 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error and Repair query
    By Andy Swain in forum Excel General
    Replies: 0
    Last Post: 08-07-2017, 04:39 AM
  2. [SOLVED] Repair unique value
    By sanju2323 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2016, 08:17 AM
  3. How to repair Excel.
    By parkman in forum Excel General
    Replies: 2
    Last Post: 03-04-2014, 05:12 PM
  4. Repair Shop Scheduler
    By andrewdugas in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-20-2013, 06:34 PM
  5. Document repair keeps comming up
    By jjjgroot in forum Excel General
    Replies: 6
    Last Post: 11-29-2012, 06:06 AM
  6. open & repair through vba
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2006, 10:45 AM
  7. excel file repair
    By Jerryfromvisalia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2005, 09:05 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