Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

In VBA excel, How do I set a String equal to a cell?

I have this :

Dim dblTotal As Double

dblTotal = 0

Dim strSize As String

strSize = Cells(mIntTask4Row, glngColumn).Value ***

Dim strTopping As String

strTopping = Cells(mIntTask5Row, glngColumn).Value ***

But I get a "Run-Time Error '1004'

Application-defined or Object-defined error"

I know that the problem is in the lines I marked with the ***, but I can't figure out how to write it correctly.

My instructions are:

Initialize dblTotal with the value 0. Put the value in cell in row mintTask4Row and glngColumn in the

variable strSize. Put the value in cell in row mintTask5Row and glngColumn in the variable

strTopping.

Update:

I also have a bunch of middle stuff and then I need a Total but this code won't work

Cells(mIntTask6Row, glngColumn).Value = dblTotal

Help?

4 Answers

Relevance
  • 8 years ago
    Favorite Answer

    Well, just do one thing

    Activate the Sheets at start: Sheets(SheetName_Here).Activate and then use Activesheet prefix before cells so you'r code look like:

    Sheets("You'r Sheet Name here").Activate

    Dim dblTotal As Double

    dblTotal = 0

    Dim strSize As String

    strSize = ActiveSheet.Cells(mIntTask4Row, glngColumn).value '***Make Suer mIntTask5Row and glngColumn should contain integer value

    Dim strTopping As String

    strTopping = ActiveSheet.Cells(mIntTask5Row, glngColumn).value '*** Make Suer mIntTask5Row and glngColumn should contain integer value

    let me know if any thing goes wrong.........lolz:)

  • 4 years ago

    1

  • puaka
    Lv 5
    8 years ago

    There is no cells() function in Excel. Cell() in singular has specific syntax with 2 parameters. For example, The first is a set of strings to choose one from eg address, col, color, contents, filename, format, parentheses,prefix, protect, row, type,width, You may need to use application.cells() as this is an Excel based function and not a vba function.

    If this is not the formula you want, then the confusing cells() function is a user defined function. Use search to find in your vba project. If you are not able to find it, this is why the function failed as it cannot be found.

    If you find it, using debugging tools, create a suspension point when the function is called and go through line by line to see what went wrong.

  • ?
    Lv 4
    5 years ago

    Once once more you believe we will do all of your homework for you, however when you consider that that is homework, you've got been subjected to extra privileged know-how to your classes than us on here, so to try and do homework for you founded on this question without the entire previous know-how you've got had isn't feasible, probably you have got to pay more awareness at school

Still have questions? Get your answers by asking now.