+ Reply to Thread
Results 1 to 10 of 10

Problem with loop coding and formatting providing a #N/A error

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    Oxford, UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Smile Problem with loop coding and formatting providing a #N/A error

    Hi

    I am fairly new to producing macros so if this doesn't make sense, I apologise.

    What I am trying to do is to produce shipping costs from a calculator that's based in another workbook. The problems that I am having are as follows:
    the calculator isn't working unless I manually type in the weight, if I copy and paste from the workbook into the calculator it returns a #n/a result
    I can't seem to get the code right to be able to work down a list of titles until I reach an empty cell.

    Any advice on either of the above 2 issues would be greatly appreciated as this is keeping me up at night now!!

    Thanks in advance

    Please Login or Register  to view this content.

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

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi, Sue991,

    Iīm not sure the calculator will accept the macro but itīs a bit shorter (and avoids a lot of changing between workbooks). Please use a copy of the original workbook for testing the code which should go into a standard module:

    Please Login or Register  to view this content.
    This code is untested - there may be occur run time errors (letīs hope they wonīt).

    Ciao,
    Holger

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    Oxford, UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi Holger

    Thank you so much, you are an absolute star! The macro appears to run and the fields are completed however I've still got the formatting issue with taking the weight figure from the worksheet and inputting it into the calculator. Any ideas?

    Thanks again
    Sue

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

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi, Sue,

    depending on what you need to enter thereīs the Format-Function which could help. Short example:

    Please Login or Register  to view this content.
    This will show a text which needs to be converted to a number (i.e. by adding 0). Same could be achieved by using Text instead of Value when transferring the data.

    Sorry, I know it sounds confused but could you be a bit more precise on whatīs exactly in the cell to copy and whatīs expected to be inserted into the calculator?

    Caio,
    Holger

  5. #5
    Registered User
    Join Date
    08-07-2012
    Location
    Oxford, UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi Holger
    The calculator that I've produced works on full numbers only however the cell that I want to take the figure from is a calculation of a print run x book weight + 6% and therefore the result is not a full number. For example print run = 200 x book weight = 0.76kgs = 153KGS + 6% = 161.12. I need to round up or down the number in order to use the calculator.
    Thanks again, your help is really appreciated.
    Sue

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

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi, Sue,

    you could utilize WorksheetFunction.Round(Cell.Value, 0) for that.

    An example for the first line of and value of a cell from the code

    Please Login or Register  to view this content.
    Or you might like to use RoundUp, RoundDown, or use Fix or Int. There are far more ways than I mentioned.

    Please give it a try.

    HTH
    Holger

  7. #7
    Registered User
    Join Date
    08-07-2012
    Location
    Oxford, UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi Holger
    Within the original code that you gave me, where should I add this line? Sorry, but I am a real novice at this
    Sue

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

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi, Sue,

    no problem - seems I havenīt been very clear on that one cause (should activate the line number for the code for clarification maybe). Assuming that itīs for all the values which are pasted into the calculator:

    Please Login or Register  to view this content.
    The original lines have been commented out - they should appear in green colour in th eeditor (by default at least).

    HTH
    Holger

    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [ code ] Your code here [ /code ] (without spaces in the brackets)

  9. #9
    Registered User
    Join Date
    08-07-2012
    Location
    Oxford, UK
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi Holger
    It's getting stuck at the following line:
    Please Login or Register  to view this content.
    Any ideas what the problem may be?
    Again, thanks for your time.

    Sue
    Last edited by Cutter; 08-24-2012 at 12:04 PM. Reason: Corrected code tags

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

    Re: Problem with loop coding and formatting providing a #N/A error

    Hi, Sue,

    whatīs the cell type in Column P? I assumed it to be numeric and thus added the Round-Function.

    Please point out if the rounding must be applied for all three cells to be carried over.

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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