+ Reply to Thread
Results 1 to 7 of 7

No correct output

Hybrid View

mukeshbaviskar No correct output 02-27-2014, 12:13 PM
Norie Re: No correct output 02-27-2014, 12:16 PM
mukeshbaviskar Re: No correct output 02-27-2014, 01:15 PM
HaHoBe Re: No correct output 02-27-2014, 01:22 PM
mukeshbaviskar Re: No correct output 02-27-2014, 11:15 PM
Norie Re: No correct output 02-27-2014, 01:20 PM
mukeshbaviskar Re: No correct output 02-27-2014, 11:40 PM
  1. #1
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    No correct output

    Hi,
    I have sr. no. in column 'b' and I want to transfer it automatically in column 'ag'. I have inserted a code in sheet code but it's giving wrong output. It transfers the value from column 'c' but I want the value from column 'b' in column 'ag'.

    The code is:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    If Target.Row < 7 Then Exit Sub
                    Application.EnableEvents = False
                    If Target.Row > 1 And Not Range(Cells(Target.Row, "c"), Cells(Target.Row, "f")) Is Nothing Then
        Set rng = Range(Cells(Target.Row, "c"), Cells(Target.Row, "f"))
        With rng
            Cells(Target.Row, 34).Value = .Cells(1) & " " & .Cells(2) & " " & .Cells(3) & " " & .Cells(4)
        
    With rng
            Cells(Target.Row, 33).Value = .Value
        End With
        End With
    End If
    
                    Application.EnableEvents = True
                    
    End Sub
    Please suggest me a correction.

    Thanking you in anticipation.

    Sincerely,

    Mukesh

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: No correct output

    You don't refer to column B anywhere in the code.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No correct output

    Hi Norie,
    Sorry, now I have modify the code but getting syntax error. Please check it.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    If Target.Row < 8 Then Exit Sub
                    Application.EnableEvents = False
                    If Target.Row > 1 And Not Range(Cells(Target.Row, "c"), Cells(Target.Row, "f")) Is Nothing Then
        Set rng = Range(Cells(Target.Row, "c"), Cells(Target.Row, "f"))
        With rng
            Cells(Target.Row, 34).Value = .Cells(1) & " " & .Cells(2) & " " & .Cells(3) & " " & .Cells(4)
        
        'Column AG
        
        If Target.Row > 1 .Range.Cells.Column "b" Is Nothing Then
        Set rng = Range(Cells(Target.Row, "b"))
    With rng
            Cells(Target.Row, 33).Value = .Value
        End With
        End If
    End With
    End If
    
    
                    Application.EnableEvents = True
                    
    End Sub
    Thank you.

    Regards,

    Mukesh

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: No correct output

    Hi, Mukesh,

    how many more times will you come with the same basic codes and claim they don´t work for you alöthough you have been supplied with better ones?

    If Target.Row < 8 Then Exit Sub
    still and always makes the check for
    If Target.Row > 1
    obsolete.

    Ciao,
    Holegr
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No correct output

    Hi Holger,
    Sorry, I don't have a problem in this line. I have inserted it in the code and it's working fine. I have a problem in the code to transfer the value of column 'b' to column 'ag'.
    I don't want to trouble you friends. I have not completed any vba course. I'm learning it from you and forum friends time to time.So I'm facing the problems. I have learned a lot of things from you to speed up my work quickly using vba. So please don't mind.

    Sorry and thank you.

    Regards,

    Mukesh

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: No correct output

    I think you are over complicating things.

    If you want to transfer the value from column B to column AG all you should need is this.
    If Target.Row > 1 And Target.Column = 2 Then
        Cells(Target.Row, "AG").Value = Target.Value
    End If

  7. #7
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: No correct output

    Hi Norie,
    Thank you. Now my problem is solved.

    Thank you Holger for guidance.


    Thank you.

    Regards,

    Mukesh
    Last edited by mukeshbaviskar; 02-28-2014 at 02:05 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Not getting correct output problem
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-19-2014, 08:44 AM
  2. [SOLVED] Error in sum formula not correct output
    By mukeshbaviskar in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-31-2014, 11:40 AM
  3. [SOLVED] Not getting correct output value( Label & (i-6) & .Top)
    By annpricks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2012, 03:44 AM
  4. Find and output correct path
    By 9437excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2011, 02:20 PM
  5. Month Function Not Displaying Correct Output?
    By NewExcelUser in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-29-2007, 03:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1