went further in the code and now im at the point where, I wanna be able to keep a summary of what I did like this
Building number unit number number area
1 101 bedroom
2 201 bathroom
10 308 living room
and so on then be able to transfer to excel, I guess have a button after I am finished with the single selections that I would click named STORE,
then after I have made all my selections, how many ever there are lets say 40, and have a summary to show me the selections, and then click the transfer button as the final step in exporting it into excel, I tried createing a form for the summary but I think I going the wrong way for this????????????
I have in finally going into excel but only one line, I need to be able to goto the next line or kust transfer all at once.
Also How and where do adjust the column settings couldn't find it in help???
Heres what I have to work with,
VB.NET:
[size=1][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Transfer_Click([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] Transfer.Click[/size]
[color=#008000][size=1]'\\ [/size]
[left][/color][size=1]MySub()[/size][/left]
[color=#008000][size=1]'\\ [/size]
[left][/color][size=1][color=#0000ff]End[/color] [color=#0000ff]Sub[/color][/size][/left]
[size=1][color=#0000ff]Sub[/color] MySub()[/size]
[size=1][color=#0000ff]Dim[/color] oApp [color=#0000ff]As[/color] [color=#0000ff]New[/color] Excel.Application[/size]
[left][size=1][color=#0000ff]Dim[/color] oWB [color=#0000ff]As[/color] Excel.Workbook = oApp.Workbooks.Add[/size][/left]
[size=1][color=#0000ff]Dim[/color] oWS [color=#0000ff]As[/color] Excel.Worksheet = [color=#0000ff]DirectCast[/color](oWB.Worksheets(1), Excel.Worksheet)[/size]
[size=1][color=#0000ff]Dim[/color] oRng1, oRng2, oRng3, oRng4 [color=#0000ff]As[/color] Excel.Range[/size]
[color=#008000][size=1]' Your Code Goes Here [/size]
[/color][size=1]oRng1 = oWS.Range("A1") [color=#008000]'building[/color][/size]
[size=1]oRng1.Value = "Building"[/size]
[size=1]oRng1 = oWS.Range("A2")[/size]
[left][size=1]oRng1.Value = CurrentBuilding[/size][/left]
[size=1]oRng2 = oWS.Range("B1") [color=#008000]'Full Building Unit Number
[/color][/size][size=1]oRng2.Value = "Unit Number"[/size]
[size=1]oRng2 = oWS.Range("B2")[/size]
[left][size=1]oRng2.Value = CurrentFullBuild[/size][/left]
[size=1]oRng3 = oWS.Range("C1") [color=#008000]'UnitArea
[/color][/size][size=1]oRng3.Value = "Unit Area"[/size]
[size=1]oRng3 = oWS.Range("C2")[/size]
[left][size=1]oRng3.Value = CurrentUnitArea[/size][/left]
[size=1]oRng4 = oWS.Range("D1") [color=#008000]'Item Catogory
[/color][/size][size=1]oRng4.Value = "Item Catogory"[/size]
[size=1]oRng4 = oWS.Range("D2")[/size]
[left][size=1]oRng4.Value = currentItemCat[/size][/left]
[color=#008000][size=1]' save the doc now? [/size]
[/color][color=#008000][size=1]'oWB.SaveAs("C:\My Documents\MyWorkbook.xls") [/size][/color]
[size=1]oRng1 = [color=#0000ff]Nothing[/color] [color=#008000]' <-- Don't forget! [/color][/size]
[size=1]oRng2 = [color=#0000ff]Nothing[/color] [color=#008000]' <-- Or Excel will hang... [/color][/size]
[size=1]oRng3 = [color=#0000ff]Nothing[/color][/size]
[size=1]oRng4 = [color=#0000ff]Nothing[/color][/size]
[size=1]Cleanup:[/size]
[left][color=#008000][size=1]'oWB.Close(SaveChanges:=False)[/size][/color][/left]
[left][color=#008000][size=1]'oApp.Quit() [/size][/color][/left]
[left][size=1]oApp.Visible = [color=#0000ff]True[/color][/size][/left]
[left][size=1]oApp = [color=#0000ff]Nothing[/color][/size][/left]
[left][size=1]oWB = [color=#0000ff]Nothing[/color][/size][/left]
[left][size=1]oWS = [color=#0000ff]Nothing[/color][/size][/left]
[left][size=1]GC.Collect() [color=#008000]' <-- *** Important! ***[/color][/size][/left]
[left][color=#008000][size=1]'clear entries for next entry[/size][/color][/left]
[left][size=1]Building.Text = "Building Number"[/size][/left]
[left][size=1]FullBuild.Text = "Unit Number"[/size][/left]
[left][size=1]area.Text = "Area"[/size][/left]
[size=1]ItemCat.Text = "Item Catogory"[/size]
[size=1][color=#0000ff]End[/color] [color=#0000ff]Sub
[/color][/size][size=1][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Area_SelectedIndexChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] area.SelectedIndexChanged[/size]
[size=1]CurrentUnitArea = [color=#0000ff]CType[/color](area.SelectedItem, [color=#0000ff]String[/color])[/size]
[left][size=1]Debug.WriteLine("Current Unit Area: " & CurrentUnitArea.ToString)[/size][/left]
[size=1][color=#0000ff]End[/color] [color=#0000ff]Sub
[/color][/size]
[size=1][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Building_SelectedIndexChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] Building.SelectedIndexChanged[/size]
[size=1]CurrentBuilding = [color=#0000ff]CType[/color](Building.SelectedItem, [color=#0000ff]String[/color])[/size]
[left][size=1]Debug.WriteLine("Current Building: " & CurrentBuilding.ToString)[/size][/left]
[size=1][color=#0000ff]End[/color] [color=#0000ff]Sub
[/color][/size]
[size=1][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] FullBuild_SelectedIndexChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] FullBuild.SelectedIndexChanged[/size]
[size=1]CurrentFullBuild = [color=#0000ff]CType[/color](FullBuild.SelectedItem, [color=#0000ff]String[/color])[/size]
[left][size=1]Debug.WriteLine("Current FullBuild: " & CurrentFullBuild.ToString)[/size][/left]
[size=1][color=#0000ff]End[/color] [color=#0000ff]Sub
[/color][/size][size=1][color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] ItemCat_SelectedIndexChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] ItemCat.SelectedIndexChanged[/size]
[left][size=1]currentItemCat = [color=#0000ff]CType[/color](ItemCat.SelectedItem, [color=#0000ff]String[/color])[/size][/left]
[left][size=1]Debug.WriteLine("Current ItemCat: " & currentItemCat.ToString)[/size][/left]
[left][size=1][color=#0000ff]End[/color] [/size][color=#0000ff][size=1]Sub[/size][/left][left][size=1]End[/size][/color][size=1][color=#0000ff] Class[/left][/color][/size]
Last edited by a moderator: