I keep getting the error "Run-Time error '13': Type mismatch" and I can't figure out why.
This is my code below, please help
![]()
Please Login or Register to view this content.
I keep getting the error "Run-Time error '13': Type mismatch" and I can't figure out why.
This is my code below, please help
![]()
Please Login or Register to view this content.
Last edited by Rachel5694; 07-13-2018 at 08:56 AM.
Just typos …
But according to forum rules :
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.
Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
(This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
I am sorry, I am new to this forum and did not know about that rule. It should be correct now. Thank you for making me aware of the rule,
Since the error is fixed, can someone please help me I'm still stuck on itThere may be an easy fix but I am fairly new to VBA so I am unable to find it.
It looks like your code is the wrong way round and you wanted:
![]()
Please Login or Register to view this content.
Last edited by romperstomper; 07-13-2018 at 10:50 AM. Reason: Missed a 'Cell' error
![]()
Please Login or Register to view this content.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
As Cell does not exists (typo) just use instead Range (or Cells in case of numeric row / column as you can read in VBA inner help) …
hm it didn't work, I am not getting any errors but nothing is happening.
I have data in sheet one that the code is supposed to pull from, then in the second sheet called "reports" I have command button that I am pressing to start the code and then populate the value "good" into the sheet "report"
What cells are you supposed to be checking? The code is checking if R2 is >= Q2.
"Range" and "Sheets" doesn't appear to be working either.
![]()
Please Login or Register to view this content.
yes that is correct. if the value of R2 is greater than or equal to the value in q2
Put a breakpoint in the code then step through it with f8 to see where it doesn't do what you expect.
Oh sorry, R2 and Q2 would be in worksheet "Sheet1"
As a beginner starter :
PHP Code:
Private Sub CommandButton3_Click()
If Range("Sheetl!R2").Value >= Range("Sheetl!Q2").Value Then Range("Report!A2").Value = "Good"
End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Since the button is on the Reports sheet, that won't work. You need to use:
not:![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
As both work, my Range syntax is just an Excel basics as you can see just with a formula instead any code …
But you may be right if the code is located in a worksheet module ! (Error #400 in this case …)
Last edited by Marc L; 07-13-2018 at 11:26 AM.
Only if the code is located within the worksheet Report module, as a beginner starter :
PHP Code:
Private Sub CommandButton3_Click()
If Sheet1.[R2-Q2] >= 0 Then [A2].Value = "Good"
End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Last edited by Marc L; 07-13-2018 at 11:35 AM.
As this kind of code is very superfluous for this kind of stuff just using a child level formula,
if really a code is needed just use the same formula, as a very beginner starter :
PHP Code:
Private Sub CommandButton3_Click()
[A2].Value = [IF(Sheet1!R2>=Sheet1!Q2,"Good","")]
End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Last edited by Marc L; 07-13-2018 at 11:45 AM.
For some reason I am getting an "Expected: Expression" error with ">=" ?
Back & Forth all night long....Just request OP to upload a sample and put them out of their misery!!!
What, and spoil all the fun?![]()
The things we do for fun lol...![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks