Resolved-How To Hide Columns With MSflexgird
Hello.
I have no problem with setting the visibility of columns for databoundgrid but I have not yet figured how to hide columns in msflex grid. And also can you use wrap text function with msflex gird. Hm. I use msflexgrid because I want each row to have a specific color determined value of a field in the row. That is not possible with databoundgrid at least in VB6. And with msfelx gird I would like to hide some colums and use wrap text function. Any ideas would be apprichiated and if someone has any ideas on costum controls that would be great. I am looking for something that has both functions of msflexgrid and databoundgrid. A freeware control somewhere?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Hide Rows Or Columns
An interesting code, for us working with complex spreadsheet, would be to know how to create a macro that would remove an entire row containing ZEROS in the cells. In example below, only the Account#70200 row should be hidden (NOT the 70400).
Example:
Account# January Feb March
70100 1,000 2,100 3,000
70200 0 0 0
70300 1,200 1,100 2,000
70400 0 2,100 2,100
Similar trick for hiding columns with zero or no values would be very usefull.
Hide All Unused Columns
Servus again,
I want to integrate a macro, that hides all unused (=empty) columns. But: the empty column, that follows directly to a not-empty column, is supposed to be unhided.
E.g.: A is empty --> hide. B is filled --> unhide, C is empty --> unhide because it follows directly to B ...
The code does not seem to work, but i don't know why... Any idea??
Here is the code:
Sub LeerKiller()
Dim row, col, dist, cont As Long
dist = 0
cont = 0
For col = 1 To 300
For row = 1 To 65000
If Not Cells(row, col) = "" Then
Columns(col).EntireColumn.Hidden = False
cont = cont + 1
Exit For
End If
Next row
If cont = 0 Then
Columns(col + 1).EntireColumn.Hidden = True
End If
Next col
End Sub
MSHFlexGrid Hide Columns
I am filling a mshflexgrid with a recordset of 4 fields. I only need to show
two of the fields in my flexgrid, and the other two fields I only need for calculation. How can I handle this ?
The grid have 4 columns; column 1 and 2 should be from the recordset, and
column 3 and 4 is additional fields. Hope someone can give me some good ideas.
How To Hide MSFlexGrid Columns
I use flex.ColWidth(5) = 0 to hide the column five but I really want to hide a column allowing the user to resize only the columns wich are not hidden. If you position the mouse between 2 colums and there is a hidden colunm between them you can resize it and becomes visible which is not what I want. Any idea will be appreciated.
Is There A Way To Hide Listview Columns?
hey guys I have a listview called report. Is there a way to hide the first column, so thats its there and the program can access it, but just hidden from the user?
Thanks!
Hide Columns In DataGrid
Dear friends,
I have 5 fields in Table Items.I created DataGrid to view the table.
I have 5 cols. as follows.
code,name,uom,desc and stock.
But I don't want to display all the columns.I want to display only
code,name and stock.How to hide other cols, Please help me to do!
DBGrid Hide Columns........
I have a DBGrid with Columns that I require, however I change the RecordSource to the DBGrid on several occasions this is to save hiding three diferent DBGrids.
As you can Imagine there are unused columns showing in the dbgrid which means you have to scrole to see parts of the data.
Is there a way to hide columns on run time?
thx
Hide Columns In Datagrid
Hi! i use a recordset to set datagrid datasource.
as below,
rs.open "select ID,name,Desc from table" 'rs recordset
set dg1.datasource=rs 'datagrid dg1
My problem is how to hide 'ID' field from the datagrid.
I dont want to display that column.
I know there's a property named 'visibleCols' in datagrid.
it gives the number of columns displayed. How can i put it
to use to hide a column. Any other alternative too will be
great!.
thnx
Mur.
Hide The Columns And Rows
Hai gurus
Can I hide some(not all not thru width =0) columns or some rows in the list view?
regards
Rajender G
Hide/Unhide Columns With One Button
Hi,
I have recently written a macro that hides and unhides a specified number of columns, but would like to build an If statement to consolidate the macro into one procedure. Here's what I'm trying to do...
I have data in columns ("A:F") and would like to be able to hide and unhide columns ("B") with the same button. So, if I click the button once, it will hide columns B,C,D. If I click the same button again, it will unhide columns B,C,D. On the third click it will once again hide the three columns.
Any help would be greatly appreciate. Thanks!
Select Sheets And Hide Columns
Hi,
I got a workbook with 46 sheets. I need to select (range) sheet 12 to 46 and hide some columns.
This is what I tried, but I wasn't really lucky with that:
Sub HideRows()
Sheets(Array("12":"46")).Select
Columns("K", "W", "AA", "AC", "AD", "AE", "AH", "AS", "AL").EntireColumn.Hidden = True
End Sub
What am I doing wrong?
Thanks in advance
How To Hide Columns And Rows Not Needed?
Hi, i would like to hide the columns and rows that i dont need when the workbook is open.
I was thinking a For loop from B3 - the last column, but how do i find out the last column?
Same goes for the row.
Also what is the command to add a row or column.
Thanks a bunch..
Hide Columns In Excel Sheet
Hi,
guys, i need help in hiding columns in excel sheet using userform on load. And but when i read data from the excel sheet, it should read from all the columns in excel sheet including from those hidden columns.
If any of you come across, please help me.
Thanks,
Chandra
How Do I Hide/unhide Columns In A List View?
I want the user to choose the columns for a specified output though all the columns will be filled
with data , i want to display only those columns which the user selects.Currently i make the width
of the hidden column as - 0 but that the user can just keep his mouse on the header and drag to
see the hidden column. How do I actually hide it???
2 Qs : Timer And How Do I Hide/unhide Columns In A List View?
hi,
2 questions
For a listview, I want the user to choose the columns for a specified output though all the columns will be filled with data , i want to display only those columns which the user selects(Like we have it in windows explorer). Currently I make the width of the hidden column as - 0 but that the user can just keep his mouse on the header and drag to see the hidden column. How do I actually hide it???
Second question:
I have just recently find out that one cannot set the interval time of a timer for than 65000 millisecs that is apporx a minute. How do I set the interval of a timer for more than a minute say 3 minutes?
Thanks.
Hide RectFocus? [RESOLVED!]
Is it possible through Code or API to hide the selection focus when clicking a listbox? I know you could just setfocus to another control such as a textbox, but my form has nothing that can setfocus too, removing the selection rectangle.
Thanks for any ideas
Form Hide Resolved
I have a program with 5 different mdi child forms. On the main form top menu bar i have a dropdown with all their names listed for quick opening of the forms Using Form .show command.But all previous forms are still loaded in the background. How do i unload them If I dont know which is open.
Hide Options In IE **RESOLVED**
Is there a way I can get my application to hide the Internet Options item in the Tools menu of Internet Explorer? I don't want them users to change the predefined url.
Thanks in advance!!
Hide/Show All IE Windows (RESOLVED)
Hey All,
I found the following code in the forums to hide/show the active IE window...
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Sub Command1_Click() Dim hApp As Long hApp = FindWindowEx(0, 0, "IEFrame", vbNullString) ShowWindow hApp, 0 'change 0 to 1 to show it againEnd Sub Private Sub Command2_Click() Dim hApp As Long hApp = FindWindowEx(0, 0, "IEFrame", vbNullString) ShowWindow hApp, 1 'change 0 to 1 to show it againEnd Sub
Can someone please show me how to put this in a loop to hide/show all open
IE windows?
Any help would be appreciated.
Thanks,
Ron
RESOLVED (I Think) - Hide Column In Listview But Use It
Hi,
Is it possible to hide a column in a listview, set to report view, but still use it? 'Cause I have a column 'SortDate' that contains dates like this: '20021011' (=11-10-2002), that makes it easy to sort them, but I don't want to show this column.
Tnx,
MK
[-Resolved-] Open And Hide A Program.
I'm using vb6
I wonder is it possible...
I would like to ask how to use code to open a file(microsoft outlook) and then hide the program(let it run at the background).
Thanks for helping me.
Edited by - lky_86 on 5/1/2004 12:01:58 AM
Looping Over Columns *RESOLVED*
I need to write code to perform a check on several cells in one row - so I need to increment the loop across columns (letters) rather than rows (numerics).
e.g. If the entries in A1, B1, C1, D1 are 5, 7, -4, 0 then how do I perform a check cell by cell from A1 to D1 to check which cells' values are negative?
Any suggestions?
M_B
Edited by - M_B on 12/19/2003 1:39:36 AM
Show/Hide Midi Children (Resolved)
I have a MDI form with several children. I'm trying to find a satisfactory way of showing & hiding the forms but have yet to do so. I'm currently using the code:
VB Code:
Private Sub mnuActionsfrmA_Click() ActiveForm.Hide If ActiveForm Is Nothing Then frmA.Show
This sems to cause several problems.
Likewise, just using frma.show has its own problems too, namely bringing the form to the front if it's already loaded.
How do other people go aobut showing/hidin/loading/unloading forms?
RESOLVED: How Can I Hide The Main Window When It First Loads?
I have a main Form1 and when the form first loads there is a bunch of initialization stuff which occurs. Instead of having the main Form1 ecome visible upon loading, I would like it to be hidden until all initializations have completed.
Currently, when the form loads I immediately do a "Form1.Hide" and then after initialization has completed I performs "Form1.Show". However, when the application is started, the outline of the main Form1 window flickers into view and then very quickly disappears due to the "Hide" method call.
Question is, how can I get rid of the "flicker" which occurs before the Form1 is loaded?
PS: I tried immediately setting the Left property of the Form1 window in the Load method to be somewhere off the screen, but I still see the flicker until this occurs. I also set the Visible property of the main Form1 during design time to be FALSE, but this did not work since I could not seem to set the visible property back to TRUE during runtime at the correct time. The main Form1 thus never became visible.
Edited by - uncletr on 3/11/2007 8:31:39 PM
Sorting Columns In Msflexgrid (RESOLVED)
Hi there...
I'm trying using an MSflexgrid and I would like the grid to automaticly sort the columns once I clic the header...
Do you guys have any good code for that?..
Thanks in advance
Listbox, Columns And How To Additems (resolved, TY)
I've created a listbox with 2 columns, in one I want a long string of information and in the other I want it to be "" blank so I can add things in later. How do I additems to which column? How does it work?
-Thank You.
RESOLVED Assign Name At Columns And Rows
Ciao Gurus,
It's possible assign a name to columns and rows and see they instead of A, B, C... and 1, 2, 3..?
Thanks
Edited by - kaiala on 1/15/2007 12:33:27 AM
How Can You Hide An 3rd Party Window From The Taskbar? (*Resolved*) - $20 Paypal
Please guys im desperate here.. i really need to know how to do this and there seems to be no resources on the net or anything.
Basically i want to create an internet explorer object, and hide it from the taskbar - but keep it active. if ie is hidden (visible=false) it doesnt function correctly. i cant use the webbrowser because the webbrowser has no toolbars. So, i have 3 ways of doing this. 1) Remove the application from the taskbar (but keep it active). 2) Run the application within my form so it doesnt add itself to the taskbar 3) Be able to add the ie toolbars to a webbrowser on my form. Anyone that can answer any of these will receive $20 from me thru paypal.. ive been looking for an answer for a week, and boss is getting very mad...
The app im trying to hide from the taskbar does not function if it is inactivated..
VB Code:
Private Declare Function ShowWindow _ Lib "user32" ( _ ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_HIDE = 0
If i use SW_HIDE, the app is removed from the taskbar but it is inactivated too, and it wont work
i need a way to just remove a app from the taskbar (i have its hwnd).
Maybe it is possible to use SW_HIDE first to remove it from the taskbar, but somehow activate the program again by showing it? Ive tried using sw_hide then using IE.Visible = True, but it adds itself to the taskbar again
I just want to remove the taskbar item, but have the window remain visible
please help me..
is it possible to use SW_HIDE to hide the app from the taskbar and inactivate it, then activate it again somehow with api?
is it possible to load an app within a vb app? (im trying to hide an internet explorer window. I cannot use the webbrowser control because the webbrowser has no toolbars like the google toolbar)
is it possible to add a toolbar to a webbrowser?
thanks
RESOLVED Filling A Textbox By Columns Not Tabs
I'm trying to fill a text box with data from a flexgrid.
The problem is that some of the data is drastically different sizes. So it creates a fairly messy text.
I want to organize them into columns, but without using tabs or tryin to find th lenght of each and every entry and adding spaces to reach a total length.
Any suggestions?
***Resolved*** Excel Columns And Rows Count
Hi All,
I would like to fined out how many columns and rows i have in my spread sheet in my excel.
I tried to get it with
wksheet.Columns.count
but it gave me all the columns and not only the one that are filled.
thank - Lin.
Properties Of Access Table/Columns ******SEMI-RESOLVED*****
When you build a table thru code (at least when I do it) the
resultatant table has all the variables as requiring entry. Ie: no
blanks.
What is the property to change this under program code? I've
looked under ADO and DAO and can't find it.
Under the General Tab in table design mode it is
marked "Required"
Thank you
MSHFlexrid Autosize Question/problem - Extra Columns After Sizing Columns To Autofit
I'm trying to use the MSHFlexGrid control, and it's almost a great thing, but not quite.
I wrote a VB app ( I'm a newbie, and my background is midrange program coding specifically RPG on an AS/400 so please keep that in mind. Event-driven programming and VB are new to me.) that will allow users to "drive" the application and select how they want to see the hierarchy. I let them choose from the pertinent fields and they are popped into a listbox control. The order in which they appear in the listbox control determines the hierarchy, and the underlying code writes the SHAPE, APPEND statements, etc...
So far, great... The problem I have is that since I have no way of knowing what hierarchy the user will select when they run the app, I have no way to know which columns will appear in the grid, or in what order, so there is no way to pre-size the column widths.
I found an autosize routine here posted by FlyGuy, so I put that code behind a button on the form called "AutoFit". When I run the code, it resizes the columns beautifully, but the column headings disappear from the sections over the "children" "grandchildren" "greatgrandchildren" , etc... columns.
Then if I do a collapse/expand, I find that the MSHFlexGrid control has a bunch of empty columns now between the original parent and child columns. The number of columns which appear are equal to the total number of child, grandchild, greatgrandchild, etc... columns fully expanded outward, so in the example shape statement below, I wind up with 16 empty columns on the control. Every subsequent autosize leaves the control with more blank columns. If I scroll far enough to the right, I find the children with their column headers.
The question I have is what is causing this ( the empty columns and the disappearing headings ) to happen, and can I do anything to stop it? I'm not sure it's usable for the end users if this continues to happen. Should I ( or can I ) dynamically set the column widths on the control at run time? Should I load the control by trying to iterate through all the recordsets and maybe do some sort of writing to the control directly? Is there a way to stop the control from showing the repeating columns in the children ( like maybe especially if I write directly to the control )? Can I ( if I write to the control ) format the columns so that numbers are right justified?
I'm using VB6 under Windows Xp Service Pack 2, and service pack 6 for Visual Studio 6 has been applied.
Here is how I was doing it: ( Warning: ugly code alert ):
Dim cnmx As ADODB.Connection
Dim rsMX As ADODB.Recordset
Set cnmx = New ADODB.Connection
Set rsMX = New ADODB.Recordset
With cnmx
.CommandTimeout = 0
.ConnectionTimeout = 0
.Provider = "MSDataShape"
.Open "dsn=<the dsn>;User ID=<the account>;Password=<the password>"
End With
rsMX.Open SQLShapeStatement, cnmx, adOpenStatic, adLockReadOnly, adCmdText
On Error Resume Next
If Err Then MsgBox Error
Set Form3.MSHFlexGrid1.DataSource = rsMX
Form3.MSHFlexGrid1.CollapseAll
rsMX.Close
cnmx.Close
Set rsMX = Nothing
Set cnmx = Nothing
Load Form3
Form3.Show
The value of the SQLShapestatement is:
SHAPE {SELECT USAGECOSTCENTER as Dept, cast(round(SUM(COST), 2) AS decimal(9, 2)) as DeptCst From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' GROUP BY USAGECOSTCENTER ORDER BY DeptCst DESC} AS Level1
APPEND ((SHAPE {SELECT USAGECOSTCENTER as Dept, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) as Equip_Num, cast(round(SUM(COST), 2) AS decimal(9, 2)) as Equip_NumCst From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' GROUP BY USAGECOSTCENTER, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) ORDER BY Equip_NumCst DESC} AS Level2
APPEND ((SHAPE {SELECT USAGECOSTCENTER as Dept, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) as Equip_Num,ITEMNUM as Part_Num, cast(round(SUM(Quantity), 2) AS decimal(9, 2)) as Part_NumQty, cast(round(SUM(COST), 2) AS decimal(9, 2)) as Part_NumCst From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' GROUP BY USAGECOSTCENTER, coalesce(left(
EQNUM,6),(right(USAGECOSTCENTER,4) + '99')),ITEMNUM ORDER BY Part_NumCst DESC} AS Level3
Append ({Select USAGECOSTCENTER as Dept, coalesce(left(EQNUM,6),(right(USAGECOSTCENTER,4) + '99')) as Line_Num, ITEMNUM as Part_Num, description as Prt_Desc, cast(round(QUANTITY, 2) AS decimal(9, 2)) as Qty, cast(round(COST, 2) AS decimal(9, 2)) as Cst, issuedate as Iss_Dte, Name as Emp_Nme From V_ISSREC_WITH_COST_AND_ASSOCIATES Where issuedate between '8/1/2007' and '8/17/2007' ORDER BY Cst DESC, Emp_Nme, Iss_Dte} as Level4
RELATE 'Dept' to 'Dept','Equip_Num' to 'Equip_Num','Part_Num' to 'Part_Num' )) RELATE 'Dept' to 'Dept','Equip_Num' to 'Equip_Num' ))
RELATE 'Dept' to 'Dept' )
Any suggestions welcome.
Resizing Columns In One Listview To Automatically Resize Corresponding Columns In Another.
I'm currently building the front end to a VB6 application. This app is largely based on entering data into a Listview. In order facilitate data entry, I need to create an editable row beneath the listview, comprising of text boxes(unless there is a better method) and an "add" button. The problem is that when a column in the Listview is moved or resized, the array of textboxes need to reflect this change of order/size, as each textbox needs to appear beneath its corresponding column. Also, if the listview contains a large number of columns, and therefore a horizontal scrollbar, the textboxes will need to scroll also... I would be very grateful for any help..! Thanks...
Sorting Array With 5 Columns By Any Column Or Columns
Hi all!
I have an array with 5 columns:
- city
- first name
- last name
- birth date
- children quantity
How can I sort this array by any column, for example by 4?
And how can I sort it by few columns, for example:
sort by 5 then sort by 1 then sort by 3?
Delete Emtpy Columns, Deleting All Columns
I've tried almost everything I can think of at this point.
I have a large report generated, imported to Excel.
The beginning of the code (not shown), breaks all merged cells, deletes blank rows, etc.
Now, I'm starting at the far right of the report and want to move column by column to the left deleting empty rows to bring the report together.
Excel 2003 SP2, VBA 6.3
Current code (not working correctly) reads:
Rows("1:1").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "END"
Term = "END"
Range("BL1").Select
While Not (ActiveCell = Term)
ActiveCell.EntireColumn.Select
delcol = False
If Value = "" Then
delcol = True
End If
If delcol = True Then
ActiveCell.EntireColumn.Delete
End If
ActiveCell.Offset(0, -1).Select
Wend
Starts by clearing all contents of row 1, places "END" in A1 so the loop knows when to close. Loop begins in BL1 and moves left until it encounters "END" (in A1) and stops.
Any suggestions or assistance would help maintain my sanity at this point!!!
Thanks in advance.
Dave
Columns(n).Autofit Error Past 257 Columns
When I run my code I get an "Application defined or object defined error" "run time error '1004'"
I thought I saw another thread with the same problem but couldnt find it.
Code:
Private Sub WriteExcelFile()
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
' Create the appropriate instances of Excel and create a new sheet
Set xlApp = New Excel.Application
Set xlWorkBook = xlApp.Workbooks.Add
Set xlWorkSheet = xlWorkBook.Worksheets.Add
' Make the application visible - just toggle the setting
xlApp.Visible = True
Dim n As Integer
For n = 1 To UBound(arrRecords)
'Size columns to data
xlWorkSheet.Columns(n).AutoFit ' <----- This is giving me the error
' Enter a value into cells
xlWorkSheet.Cells(n + 1, 1).Value = Format(arrRecords(n).string1, "#0")
xlWorkSheet.Cells(n + 1, 2).Value = arrRecords(n).string2
xlWorkSheet.Cells(n + 1, 3).Value = Format(arrRecords(n).string3, "#0")
xlWorkSheet.Cells(n + 1, 4).Value = arrRecords(n).string4
xlWorkSheet.Cells(n + 1, 5).Value = arrRecords(n).string5
If arrRecords(n).string6 = 0 Then
arrRecords(n).string6 = 0
Else
xlWorkSheet.Cells(n + 1, 6).Value = Format(arrRecords(n).string6, "$###,##0.00")
End If
If arrRecords(n).string7 = 0 Then
arrRecords(n).string7 = 0
Else
xlWorkSheet.Cells(n + 1, 7).Value = Format(arrRecords(n).string7, "$-###,##0.00")
End If
xlWorkSheet.Cells(n + 1, 8).Value = arrRecords(n).string8
xlWorkSheet.Cells(n + 1, 9).Value = arrRecords(n).string9
xlWorkSheet.Cells(n + 1, 10).Value = arrRecords(n).string10
xlWorkSheet.Cells(n + 1, 11).Value = arrRecords(n).string11
xlWorkSheet.Cells(n + 1, 12).Value = arrRecords(n).string12
xlWorkSheet.Cells(n + 1, 13).Value = arrRecords(n).string13
xlWorkSheet.Cells(n + 1, 14).Value = arrRecords(n).string14
xlWorkSheet.Cells(n + 1, 15).Value = arrRecords(n).string15
xlWorkSheet.Cells(n + 1, 16).Value = arrRecords(n).string16
Next
' Save the spreadsheet
xlWorkSheet.SaveAs "C: est.xls"
' Quit Excel
xlApp.Quit
' Clean up objects
Set xlApp = Nothing
Set xlWorkBook = Nothing
Set xlWorkSheet = Nothing
End Sub
Thanks
Edited by - epatterson78 on 5/25/2003 1:03:58 PM
Adding Columns To A Listview That Already Has Columns
Hi
I'm new to VB6 (I usually program in VB.NET but have been asked to make an enhancement to a VB6 application).
I have a listview which has columns defined within it in the designer. The code I am looking at then retrieves data from a db and puts it into the listview.
I've been asked to add another column in the middle of the listview e.g. there are 10 columns defined in the designer and this new column needs to go at position 6. However, the data that needs to go in the new column needs to come from a different query than the one that fills the other columns. I therefore thought that the best way to do it was fill up the original columns and then slot in the new column and fill it from another query. I've been searching around but can't find any example of how to do this.
Please can anyone help, or suggest a better way to do it? Thanks!
Scroll Bars - "Hide Or Not To Hide" Is The Question
I have a textbox that needs scrollbars "sometimes", obviously when the text "won't" fit in the box. Hmmmm - Is there a way (Of course there is stupid, you just don't know), <throat clears>:-(, <dignified posture again>, to tell the application to only show the scrollbars when the text "won't" fit in the box?????
Sal
Compare 2 Columns With 2 Other Columns?
Hi,
anybody know of a way I can quickly compare 2 columns on sheet 1 with 2 others on sheet 2?
Eg:
Sheet1:
ColA ColB
A 1
B 2
C 3
D 4
Sheet2:
ColA ColB
A 1
B 2
C 6
E 5
D4 appears on sheet 1 but not on sheet 2, E5 appears on sheet 2 but not on sheet 1, and C has a diff value (3 on sheet 1 and 6 on sheet 2), so Sheet3 would need to show:
Sheet3:
ColA ColB
D 4
E 5
C 6
So far I'm using the code below, but it only works when comparing one column with another:
Code:
Sub Compare_Columns()
Dim wsSheet1 As Worksheet
Dim wsSheet2 As Worksheet
Dim wsSheet3 As Worksheet
Dim rnLastC As Range, rnLastD As Range
Dim rnA As Range, rnB As Range, rnValue As Range, rnCell As Range
Set wsSheet1 = ThisWorkbook.Worksheets(1)
Set wsSheet2 = ThisWorkbook.Worksheets(2)
Set wsSheet3 = ThisWorkbook.Worksheets(3)
With wsSheet1
Set rnA = .Range(.Range("A1"), .Range("A65536").End(xlUp))
End With
With wsSheet2
Set rnB = .Range(.Range("A1"), .Range("A65536").End(xlUp))
End With
With rnB
For Each rnCell In rnA
Set rnValue = .Find(rnCell.Value, LookIn:=xlValues)
On Error Resume Next
If rnValue Is Nothing Or rnCell.Value <> rnValue.Value Then
On Error GoTo 0
With wsSheet3
Set rnLastC = .Range("C65536").End(xlUp).Offset(1, 0)
End With
rnLastC.Value = rnCell.Value
End If
Next rnCell
End With
Sheets("Sheet3").Select
End Sub
Any help would be greatly appreciated!!
Edit by italkid: VB tags do make your code easier to read
Hide A Tab
Does anyone know how to hide a particular tab on an sstab control. e.g. sstab1.tabs(0).visible = false (only that function doesn't seem to exist)
Hide
How can i hide my application so my program can runs in background you can only view it in your taskbar?
|