Announcement

Collapse
No announcement yet.

copy cell data to another sheet and save it automatically

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • copy cell data to another sheet and save it automatically



    Hello guys,

    i need a vba
    if condition is met then copy cell data to another sheet and save it automatically
    or
    if condition is met then take a screen shot and past it to sheet or save it as pic automatically.
    plz help how to write vba for this?
    thanks in advance

  • #2
    You need to provide more information.

    What is the condition?
    Which sheet and which range applies?

    Attach a small example workbook
    Hope that Helps

    Roy

    New users should read the Forum Rules before posting

    For free Excel tools & articles visit my web site

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

    Comment


    • #3
      Thanks RoyUk for your quick response,

      the value in bu8 and bu6 changes after few seconds,
      if value in bu8 is greater than 0 then value of bu8 and bu6 copy to next sheet and save it or
      if value in bu8 is greater than take a screen shot of all worksheet or bu8 columns and save it in jpeg.
      the data in bu8 and bu6 changes by rand function that is calculates after every 10 seconds..
      my some friend say it can be solved by event on record but they don't know the whole procedure...
      Attached Files

      Comment


      • #4
        What is triggering the changes?
        Hope that Helps

        Roy

        New users should read the Forum Rules before posting

        For free Excel tools & articles visit my web site

        RoyUK's Web Site

        royUK's Database Form

        Where to paste code from the Forum

        About me.

        Comment


        • #5
          recalculating
          i used a vba

          Sub calculate_range()
          Range("aj2:aj70705").Calculate
          Application.OnTime DateAdd("S", 2, Now), "calculate_range"
          End Sub

          Comment


          • #6
            dear use this file
            its fully functioned. thanks
            Attached Files

            Comment


            • #7
              Originally posted by royUK View Post
              What is triggering the changes?
              recalculating
              i used a vba

              Sub calculate_range()
              Range("aj2:aj70705").Calculate
              Application.OnTime DateAdd("S", 2, Now), "calculate_range"
              End Sub

              Comment


              • #8
                Your code is running every two seconds, It would take longer than two seconds to do what you want.

                Also, you have worksheet change event code in a Standard Module, this should be in the worksheet module
                Hope that Helps

                Roy

                New users should read the Forum Rules before posting

                For free Excel tools & articles visit my web site

                RoyUK's Web Site

                royUK's Database Form

                Where to paste code from the Forum

                About me.

                Comment


                • #9
                  timing is no problem if i get what i want.

                  Comment


                  • #10
                    this code working but i wan to make it auto work and only if condition is met
                    if bu8>0 then it should copy selected range automatically to sheet 2

                    Code:
                    Sub UpdateData()
                    If Hour(Time) >= 3 And Minute(Time) >= 1 Then
                    Application.OnTime Now + TimeValue("0:0:5"), "UpdateData", False
                    Else
                    Application.OnTime Now + TimeValue("0:0:5"), "UpdateData"
                    CopyData
                    End If
                    End Sub
                    Sub CopyData()
                    Dim sht1 As Worksheet
                    Dim sht2 As Worksheet
                    Dim cRng As Range
                    Dim dCol As Long
                    Set sht1 = ThisWorkbook.Sheets("Sheet1")
                    Set sht2 = ThisWorkbook.Sheets("Sheet2")
                    Set cRng = sht1.Range("Bu1:bu8")
                    dCol = sht2.Cells(2, Columns.Count).End(xlToLeft).Column + 1
                    sht2.Range(Cells(2, dCol).Address, Cells(8, dCol + 1).Address) = cRng.Value
                    End Sub
                    Last edited by royUK; 4 weeks ago. Reason: Please read the Forum Rules, I've added Code Tags this time.

                    Comment


                    • #11
                      I have added code to the worksheet calculate event that will trigger the update macro.

                      You need to read this to understand where you should be putting your code

                      http://excel-it.com/excel_vba_paste_code.html
                      Attached Files
                      Hope that Helps

                      Roy

                      New users should read the Forum Rules before posting

                      For free Excel tools & articles visit my web site

                      RoyUK's Web Site

                      royUK's Database Form

                      Where to paste code from the Forum

                      About me.

                      Comment


                      • #12
                        i am using vba 1st time in my life don't know what to write and where to write. i copy that code from websites...

                        Comment


                        • #13
                          i made some changing now its working but i want data don't update after every 5 seconds as vba says but only if condition is met
                          i mean vba updatedata only work if cell Bu8>0 then it copy otherwise do nothing.
                          How to do that?
                          Attached Files

                          Comment


                          • #14
                            I did say that your code was repeating every few seconds.

                            I've amended your code so that you don't keep repeating.

                            I've used the worksheet calculate event to check BU8 each time the sheet calculate, if the value <> 0 then it copies the data.
                            Hope that Helps

                            Roy

                            New users should read the Forum Rules before posting

                            For free Excel tools & articles visit my web site

                            RoyUK's Web Site

                            royUK's Database Form

                            Where to paste code from the Forum

                            About me.

                            Comment


                            • #15


                              Sir file you uploaded has been corrupted it doesn't work.
                              Attached Files

                              Comment

                              Working...
                              X