« first day (1265 days earlier)      last day (1915 days later) » 
00:00 - 22:0022:00 - 00:00

10:02 PM
@this hehe..
set foo = Application.Evaluate("INDEX(tblShipToLocations[Selection],MATCH(Header_Account,tblShipToLocations[Customer],0),1):INDEX(tblShipToLocations[Selection],MATCH(Header_Account,tblShipToLocations[Customer],1),1)")
?foo.address
$P$2:$P$5
#HACK
 
Now build another hack on top of that one.
 
    If IsMissing(filterColumn) Or IsMissing(filterValue) Then
        values = Application.Transpose(LocationsTable.ListColumns(columnName).DataBodyRange.value)
    Else
        Dim src As Range
        Set src = Application.Evaluate("INDEX(" & LocationsTable.Name & "[" & columnName & "],MATCH(" & filterValue & "," & LocationsTable.Name & "[" & filterColumn & "],0),1):INDEX(" & LocationsTable.Name & "[" & columnName & "],MATCH(" & filterValue & "," & LocationsTable.Name & "[" & filterColumn & "],1),1)")
@IvenBach ^^
 
#ChallengeCompleted
 
that feels quite awesome actually
in a dirty way... but awesome nonetheless
 
Don't forget to 'comment your code with why.
The more I work with VS the clunkier the VBA IDE feels.
 
10:10 PM
    'note: the dynamic range requires the table to be sorted by [filterColumn]
^ pretty much all I need
...hmm and that's an assumption right now
 
I can't wait for 3.0 when cool goodies start flowing in.
 
find v1.0, you'll feel better about 2.1.x :)
 
yeah... not a chance that's gonna happen.
 
omg that's so cool, it works!!
 
What is that?
 
10:20 PM
the form I'm working on
well, part of it anyway
 
In VBA?
 
yeah
 
Isn't that just a tooltip? I'm having another disconnect moment apparently.
 
lol, it is... the cool thing is that the model validation correctly triggers the correct error when I supply a Code that already exists for the CustomerAccount that's selected
that's what the above hack was trying to achieve
 
:lightbulb: Ah! That is pretty nifty.
 
10:23 PM
I need this thing as #IdiotProof as I can get it
 
I've seen some pretty #HackTastic things with Evaluate before.
I bid you luck on that quest. Every day more powerful foes are released.
 
I never use Evaluate. But when I do, I make it do things only it can do.
 
FYI you don't need Access to have ACE engine
in fact it's likely already included, so you could run ADO commands against Excel sheet using ACE provider.
 
Oh man... Just implemented an Interface on my test/learning project. It came about naturally too without thinking too hard. #WarmFuzzies
 
and congrats on resolving the dilemma!
 
10:32 PM
:kneejerk: Where's my alt+enter...
 
@this okay another one: if I want to refresh a table's sorting after I inserted a record, I do MyTable.Sort.Apply
 
MyTable is the type of ListObject?
 
..and Excel prompts whether I want to treat text that looks like text like text or numbers
yeah
I need to somehow skip that dialog
 
hmm. lemme see
 
Application.DisplayAlerts=False doesn't cut it
 
10:35 PM
I think I pre-format the Excel worksheet before I dump the data and make it a ListObject
 
the list is already there, already sorted
I have code that adds a new row, and then I need to re-apply the sorting
 
yes, referring to the underlying sheet that contains the table
e.g. I select the entire columns that the table needs to fit then format the columns accordingly
I do not trust that General
 
hmm, IOW having one single format in the column fixes it
facepalm
 
did you need multiple formats?
if that's the case, make it a Text
or stop using Excel like a database. :p
 
no - I'm fine with text format - but some values are e.g. "MAIN", others are "101"
@this trust me, I'd love to - and I can't here.
 
10:43 PM
ah, and Excel wants to help you.
 
#ThankYouExcel
 
So confirming - even if you pre-format the columns, it still give you that dialog when you enter a "number" in a Text-formatted column?
 
yeah
 
drats
 
and these sheets are going to be hidden... hold on, might be that
 
10:45 PM
getting my code...
 
dammit Excel
 
clarify - so it was because it was hidden?
 
no
it's going to be distributed with the data sheets hidden
but hiding them doesn't change anything
it still prompts
 
ok
which is going to be #VeryConfusing
 
about to SendKeys("ENTER")
ugh
I think I got it
 
10:51 PM
hmm, this isn't external, right?
 
nope.. well not for now
 
I do see a PreserverFormatting
 
might be, eventually
 
but it's a member of the QueryTable object, which you need for an external data source to drive the ListObject
I have this code....
 
I added a TextCode column with =TEXT([@Code],"@") for a formula
trying that .....AND IT STILL PROMPTS FFS
 
10:52 PM
With xlWkSt.ListObjects.Add( _
        SourceType:=xlSrcExternal, _
        Source:="OLEDB;blah, _
        Destination:=xlRng _
    )
        With .QueryTable
            .CommandType = xlCmdSql
            .CommandText = Array( _
            "SELECT * FROM """ & strConnect & """.""dbo"".""qryRptBatchPlantJobsWithoutProduction""")
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
PresreveColumnInfo and RefreshStyle might have some effect, IDK.
 
With AccountsTable.Sort
    .SortFields(1).DataOption = xlSortTextAsNumbers
    .SortFields(2).DataOption = xlSortTextAsNumbers
    .Apply
End With
guess what
 
nice! Didn't even know about DataOption
 
it still prompts
 
no... don't tell me it prompts even with that.
 
yup
 
10:55 PM
#WTFExcel
Quick, look under the settings and see if Clippy's hiding there.
 
oh wait a sec
YESSS!! I WIN!!!
 
sooo, what was the final solution?
 
(I had it on the CustomerAccounts table, needed it on the AccountLocations table too)
yeah. works like a charm
 
ahh, GTK. Will need to remember DataOptions for the next time.
 
it's per-field
which is annoying
but hey, works
 
10:57 PM
yeah, obviously.
at least you could just loop
 
yeah but in this case I can totally hard-code it
 
and next year you will be going "WTF why did I hard code it?!?"
:p
 
the sorting is required, so that all ship-to locations under a given account are grouped together (even after inserting one) - so that my data validation dropdowns can work
i.e. you pick an account, the dynamic named range gets the ship-to locations for it
 
Ah.
 
I have a similar mechanism for sales reps -> accounts
i.e. if the sort fields need to change, the whole data validation goes to hell
 
11:00 PM
Geez. Kind of fragile.
(sorry)
 
well, the data sheets are hidden for a reason :)
I agree it's kind of frail, but data validation is fun like that
 
Indeed, but I do hope you do get a database sooner than later because this won't scale.
 
the data comes from Sage ERP, and the worksheet is an order form that goes to sales reps that aren't connected to our domain. I can't have it connected to a db
 
Yeah, that's why we just use Excel as output -- they're great for what-if analysis, charing, pivoting, but as a data store... they suck.
 
it's literally an order form app
and with that, I got the order header part completed
 
11:03 PM
I hear you. But you're thinking database = big iron server. Doesn't have to be that. Could be local database to store the data and provide SQL queries consumed by Excel.
Use sqlite, use ACE, whatever, then it can float on its own
 
not going to happen
they want spreadsheets
correction - they want spreadsheets that work like a web application
I don't make the specs
 
misread- thought you needed it disconnected from web.
 
oh, it is
if it were, I'd be writing C# in an ASP.NET MVC app instead
and.. wait for it... JAVASCRIPT
 
but yeah, I know the pain - users want the devil they know.
 
esp. the 70yo ones
 
11:06 PM
Hosch, hear that? Mat likes his JavaScript.
 
lol nope
 
going to update the wiki on UI design based on recent discussion w/ Hosch
 
> Modal dialogs are WinForms forms. As of v2.0, redesigning them in XAML isn't yet in scope.
ouch
 
there's a statement there: As of v2.0, redesigning them in XAML isn't yet in scope. -> them implies the dialog itself. Do we hope to make them 100% WPF one day, or will they remain WinForms dialog hosting WPF elementhost as it is now?
heh. too slow.
yeah, that's why I want to update it.
just confirming we have no plan to get rid of WinForms dialog themselves; only the contents within.
 
we can't have a WPF Window in the project (even if we wanted) - so it's always going to have to be a WinForms dialog, but we'll want it to have a WPF control host and do the actual UI work in XAML
 
11:12 PM
thought so. updating...
 
tks
 
After midnight here but I would like to finish a thing here.
Is there a way to "filter" a 2D-Array?
I've got data:
 
6:21PM here, heading out of office for now
@SonGokussj4 looks like a ListObject ..should be pretty easy to filter :)
 
Oh. Do you have 5 minutes?
My problem is, I need to get this transposed table (ID_REF would be UP, 1, 2, 3 as rows) into ListBox but only for filtered columns. Like only for "CUR_TYPE" and "SRC_TYPE".
The final product in ListBox would be:
Rows "1, 2, 3, 4"
Columns "CUR_TYPE", "SRC_TYPE"
My current code is this:
Dim ctrl As MSForms.ListBox
Set ctrl = Me.Controls("lbxHARD")

Dim ws As Worksheet
Dim table As ListObject
Set ws = ActiveWorkbook.Sheets("csv")
Set table = ws.ListObjects("CURVE")

With ctrl
.Clear
.ColumnHeads = False
.ColumnCount = table.HeaderRowRange.Columns.Count


ReDim Myarray(table.DataBodyRange.Rows.Count, table.DataBodyRange.Columns.Count)

Dim rw As Long, j As Long
rw = 0

For i = 1 To table.DataBodyRange.Rows.Count
For j = 0 To table.DataBodyRange.Columns.Count
Myarray(rw, j) = table.Range.Cells(i, j + 1)
The problem is when I tried to filter the Range like this:
        Dim NewRng As Range
        Set NewRng = table.HeaderRowRange
        Dim myRow As Range
        For Each myRow In table.Range.Rows
            If myRow.Columns(1).value = "CUR_TYPE" or myRow.Columns(1).value = "SRC_TYPE" Then
                Debug.Print myRow.Address
                Set NewRng = Union(NewRng, myRow)
                Debug.Print NewRng.Address

            End If
        Next myRow
        Dim Myarray() As Variant

        ReDim Myarray(table.DataBodyRange.Rows.Count, table.DataBodyRange.Columns.Count)
It fails on the last row because the range is now
$B$95:$AC$95,$B$97:$AC$97,$B$99:$AC$99
 
Another option, I think, is to fill the whole array and then delete "rows" that doesn't match the "CUR_TYPE" or "SRC_TYPE" in the 1st array dimension and redim the row.

But I think that's a little bit complicated.
Anyway: Just trying to show ListObject in MSForms.ListBox but not all rows just those matching a list of strings.
 
Disclaimer: Not an Excel expert: I don't get it, @SonGokussj4 - why can't you just iterate the table.DataBodyRange.Rows and just fill the array (or the listbox directly) by reading the row?
 
@this You may be true. Maybe I'm overcomlicating things... It's late :-) Will try that in the i-j cycle. Be back in a minute.
 
Duck check: For List<T> is there a way to modify it's content at a specific element?
 
Sure, @IvenBach
However, I'd add that if you are doing stuff like .IndexOf(2), it's likely a code smell.
More likely, you'll want to do something like.... list.SelectSingle(x => { blah; }) = whatever;(noting that you may get an exception if the criteria isn't matched)
 
@this This is just rewriting an example. I know it's not a best practice and I don't have any intention of making it a habit.
 
Foo.IndexOf(n) = Bar where Foo = List<int> and Bar is of type int
I get Left-hand side of an assigment must be a variable, property or indexer based on my comprehension that means that Foo.IndexOf(n) is only a get accessor.
 
11:55 PM
I'm sorry. I think I forgot that the List isn't as flexible.
let me double check that.
 
If not I could always RemoveAt() and Insert().
 
35
Q: How to replace list item in best way

Ragavanif (listofelements.Contains(valueFieldValue.ToString())) { listofelements[listofelements.IndexOf(valueFieldValue.ToString())] = value.ToString(); } I have replaced like above. Is there any other bestway to place compare than this one?

@Duga @Mat'sMug @Hosch250 I think that's good; whenever you can, have a look to ensure I didn't write any outright lies. :) I might have told my grandmother how to suck eggs but I felt it necessary to make it clear we have 2 layered patterns which isn't all that obvious.
 
00:00 - 22:0022:00 - 00:00

« first day (1265 days earlier)      last day (1915 days later) »