lundi 20 septembre 2021

if function is not working in VBA even if the statement is correct

I was trying to do a VBA for cross checking the correct column is available in the order or not. here in clipboard the variable is "User Name" exactly same. But the msgbox is not pop up with the message

Sub macro1()
 
Dim Mystring As String
Dim DataObj As New MSForms.DataObject
    Range("A1").Select
    Selection.Copy
    DataObj.GetFromClipboard
    Mystring = DataObj.GetText
        If Mystring = "User Name" Then
            MsgBox "Correct column"
        End If
 End Sub

i am beginner with codes, any one can please help me?.

My requirement is: I want to check a excel file report and arrange that data in a particular order.

For example if the Colums is in A,B,C,D,E,F,G order i want to change the cloums into C,A,B,G,E,F,D order with below data as well.

Aucun commentaire:

Enregistrer un commentaire