Posts by shg

    Re: Excel list into Microsoft word


    If you copy a named range from Excel and paste/link into Word, it might look like this:


    [TABLE="width: 253"]

    [tr]


    [td]

    639

    [/td]


    [td]

    642

    [/td]


    [td]

    263

    [/td]


    [td]

    157

    [/td]


    [td]

    641

    [/td]


    [/tr]


    [tr]


    [td]

    160

    [/td]


    [td]

    5

    [/td]


    [td]

    288

    [/td]


    [td]

    416

    [/td]


    [td]

    903

    [/td]


    [/tr]


    [tr]


    [td]

    701

    [/td]


    [td]

    255

    [/td]


    [td]

    205

    [/td]


    [td]

    82

    [/td]


    [td]

    473

    [/td]


    [/tr]


    [tr]


    [td]

    727

    [/td]


    [td]

    536

    [/td]


    [td]

    501

    [/td]


    [td]

    494

    [/td]


    [td]

    550

    [/td]


    [/tr]


    [tr]


    [td]

    314

    [/td]


    [td]

    451

    [/td]


    [td]

    160

    [/td]


    [td]

    718

    [/td]


    [td]

    30

    [/td]


    [/tr]


    [/TABLE]


    If you then do Alt+F9 (Toggle Field Codes), the field looks like this:


    {LINK Excel.Sheet12 "C"\\somepath\somefile.xlsx" "RawData!wi" \a\f\4 \h}


    ... where RawData is the name of the worksheet and wi is the named range.


    Assuming the named range is dynamic (i.e., it adjusts when data is added or removed), then insertions and deletions in Excel will track when you update fields in Word.






    [TABLE="width: 253"]

    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [/TABLE]

    Re: VBA Custom Function - Automation Error


    Maybe a little clean-up:


    Code
    1. Public Function StartingVd(VdStart As Double, Uv As Double, _
    2. LRC As Double, pfStart As Double, _
    3. Rc As Double, Xc As Double, NumRun As Double) As Double
    4. Const Sqr3 As Double = 1.73205080756888
    5. StartingVd = VdStart * Uv * 1000# / (LRC * Sqr3 * (Rc / NumRun * pfStart + (Xc / NumRun * Sqr(1 - pfStart ^ 2))))
    6. End Function

    Re: UDF


    [TABLE="class: grid"]

    [tr]


    [td]

    Row\Col

    [/td]


    [td]


    A


    [/td]


    [td]


    B


    [/td]


    [td]


    C


    [/td]


    [/tr]


    [tr]


    [td]


    1


    [/td]


    [td]

    Hai cho Ba

    [/td]


    [td]

    aaBchHio

    [/td]


    [td]

    B1: =Alpha(A1)

    [/td]


    [/tr]


    [/TABLE]


    Re: Method 'Range' of object '_Global' failed


    Object variables (which include ranges) require Set, but you don't need one here.



    Also, the sequence of random numbers will repeat each time the VBE is reset. To avoid that, put Randomize at the beginning of the code.

    Re: Deleting checkboxes


    An alternative is to use Marlett checboxes. They have the advantage of being on the same layer of the worksheet as other cells, and can be easily implemented in VBA.


    Search the forum for many examples.

    Re: Conflicting VBA codes


    Every time your toggle button code changes the worksheet, the change event is firing, and your change event code isn't testing what got changed.


    One way:


    Code
    1. Private Sub Worksheet_Change(ByVal Target As Range)
    2. With Me.Range("C26")
    3. If Target.Address = .Address Then Me.Rows("83:121").Hidden = .Value <> 1
    4. End With
    5. End Sub