+ Reply to Thread
Results 1 to 3 of 3

Correction required in Code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-30-2023
    Location
    INDIA
    MS-Off Ver
    OFFICE 2016 ver 16
    Posts
    172

    Correction required in Code

    DEAR EXPERTS

    I HAVE GETTING ERROR IN CODING PLEASE BE CORRECT

    Sub Copy_Data()

    Application.ScreenUpdating = False

    Dim rangeStart As Integer
    Dim rangeEnd As Integer
    Dim rangeCalc As Integer
    Dim rangeColumn As Integer
    Dim rowSheet1DataStart As Integer
    Dim rowSheet1DataEnd As Integer
    Dim priceOneResult As Integer
    Dim priceTwoResult As Integer

    Dim dataRange As Range
    Dim foundDataRange As Range

    rowSheet1DataStart = 5
    rowSheet1DataEnd = Sheet1.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row


    Set dataRange = Sheet1.Range("A" & CStr(rowSheet1DataStart) & ":A" & CStr(rowSheet1DataEnd))

    rangeStart = Sheet1.Range("BA2").Value
    rangeEnd = Sheet1.Range("BB2").Value
    rangeColumn = 15

    ' create the line with the range values, for every 100 step
    For rangeCalc = rangeStart To rangeEnd Step 100

    Data_Opening.Cells(22, rangeColumn).Value = rangeCalc
    Data_Opening.Cells(22, rangeColumn + 3).Value = rangeCalc

    Set foundDataRange = dataRange.Find(rangeCalc, LookIn:=xlValues)

    If Not foundDataRange Is Nothing Then
    ' the range valus was found
    priceOneResult = foundDataRange.Offset(0, 52).Value
    priceTwoResult = foundDataRange.Offset(0, 55).Value
    Else

    priceOneResult = -1
    priceTwoResult = -1
    End If

    Data_Opening.Cells(23, rangeColumn).Value = priceOneResult
    Data_Opening.Cells(23, rangeColumn + 3).Value = priceTwoResult

    rangeColumn = rangeColumn + 1
    Next rangeCalc

    Application.ScreenUpdating = True

    End Sub

  2. #2
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    468

    Re: Correction required in Code

    Hello @RUPESHRH.
    You are using Data_Opening as a variable. But this variable is not initialized anywhere in your procedure. This variable must be declared as an object and only then assigned to the worksheet of the workbook. Perhaps you took an example of this code from somewhere and cut it down thinking that you could adapt it to your needs. Attach a file with an example code to your message in accordance with the forum rules, read the yellow banner at the top of this page. Then it will be clearer to those helping you to help.
    Update!
    Or:
    Dim Data_Opening As Worksheet
    Set Data_Opening = ThisWorkbook.Worksheets("Sheet2") 
     ' like Example
    Good luck.
    Last edited by MikeVol; 02-19-2024 at 02:01 PM. Reason: Update
    NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
    You can say "Thanks" in your thread to everyone who offered to help you.
    You can also reward them by clicking * "Add Reputation" under their username on the left.
    With Regards, MikeVol.

  3. #3
    Forum Contributor
    Join Date
    05-30-2023
    Location
    INDIA
    MS-Off Ver
    OFFICE 2016 ver 16
    Posts
    172

    Re: Correction required in Code

    Dear MikeVol

    i got the correction by your suggestions

    Thanks for Suggestion

+ 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] Formula correction required
    By $mart Group in forum Excel General
    Replies: 6
    Last Post: 11-29-2019, 02:33 AM
  2. Sumif formula correction required
    By Shihab in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-03-2015, 04:08 AM
  3. [SOLVED] Formulae Correction Required - Date
    By jon112211 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-06-2015, 01:09 PM
  4. [SOLVED] Formula correction required
    By mukeshbaviskar in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-18-2014, 08:31 AM
  5. vlookup formula correction required
    By mukeshbaviskar in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-03-2013, 10:52 PM
  6. Correction in the IF and VLOOKUP Formula Required
    By santhoshie in forum Excel General
    Replies: 5
    Last Post: 08-18-2011, 10:02 AM
  7. correction in formula required
    By khushee in forum Excel General
    Replies: 2
    Last Post: 06-14-2011, 03:55 AM

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