• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA for Row Difference

parth007

Member
Need to write a VBA or below..

My Macro sheet name which have Button is known as Summary
Summary Workbook have Command button..
Now When user clicks this command button then below should be done..
1) After button click Vba should ask for the other file to be open
2)Once user select file path Vba should open the file & ask for sheet name on which user want to work.
3) Once sheet is selected & active then VBA should consider two columns
Column "J" & Column "M" and check the row difference and highlight it.
Attached is the Summary workbook & Input workbook.
Note - The Input workbook and sheet name may be by any name..
User should manually select Workbook & Sheet in it
Can anyone please suggest on this
 

Attachments

  • Input.xlsx
    9.3 KB · Views: 2
  • Summary.xlsm
    12.6 KB · Views: 2
I written the code which is running fine..
Below code will Ask user to open filename & then ask to type which sheet user wants to work..
I am waiting that how do i now consider column J & column M and find row difference..

Code:
Private Sub CommandButton1_Click()
''This will prompt user to open the excel file which user wants to work on..
  Dim strFileToOpen As String
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),")
If strFileToOpen = "False" Then
MsgBox "No file selected.", vbExclamation, "Sorry!"
Exit Sub
Else
Workbooks.Open Filename:=strFileToOpen
End If
''''
Dim strName As String, ws As Worksheet

strName = Application.InputBox("Please enter the Sheet name")

strName = strName

On Error Resume Next

Set ws = Worksheets(strName)

If Not ws Is Nothing Then 'sheet exist
  Sheets(strName).Select
Else 'sheet does not exist or the entry is otherwise invalid
  MsgBox "The sheet doesn't exist or you entered the name incorrectly"
End If

Set ws = Nothing
End Sub
 
Back
Top