[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Please, is anyone good with Excel VBA? I need help, please!!

This is a red board which means that it's strictly for adults (Not Safe For Work content only). If you see any illegal content, please report it.

Thread replies: 14
Thread images: 2

File: Helpppppp.png (152KB, 1558x1000px) Image search: [Google]
Helpppppp.png
152KB, 1558x1000px
Please, is anyone good with Excel VBA?

I need help, please!!
>>
What do you need help with
You should try /g/ too
>>
I am. But post your specific problem or I can't help.
>>
>>39565091
>try /g/
I did in the stupid question thread and got no response. Here's the script (not copied exactly):

Private sub workbook_sheetchange(....)

Dim abcrow as Long
Dim sheeit as Worksheet

Set sheeit = worksheets("audit")

If sh.name = sheeit.name then exit sub

App enable events = false
abcrow = sheeit.range("A65535").end (xlup).row + 1
abcsamerow = sheeit.range("A65535").end (xlup).row

sheeit.cells (abcrow, 1).value = now
sheeit.cells (abcrow, 2).value = environ (username)
sheeit.cells (abcrow, 3).value = sh.name
sheeit.cells (abcrow, 4).value = target.adress
sheeit.cells (abcrow, 5).value = target.value


if sheeit.cells(abcsamerow, 3).value = "x" and sheeit.cells(abcsamerow, 4).value =
"y" and sheeit.cells(abcsamerow, 5).value = "z" then
worksheets("audit").range(cells (abcrow, 1), cells(abcrow, 5)).clearcontents
end if
App enable events = true
End sub


It's the last if block thats showing problems. It's not sticking to the condition of if cells = "x", "y", "z", then delete row contents -- its just doing it for all new entries
>>
Please bros, is ^ sufficient info?
>>
A bit hard to tell with that code without full context. Why don't you explain what you are trying to so instead? That code looks needlessly complicated, it can for sure be done much simpler.
>>
>>39565907
I'm trying to make a tracker sheet that shows a timestamp, the user, the sheet name, the cell location where the change was made and the value entered into said location.

In the tracker sheet, when the sheet name is "x" and the cell reference is "y" and the value entered is "z", I want it to clear the contents on this row.

I have a "this workbook by value change" sub running to auto update a pivot table after every action made, so that gets repeatedly logged into the tracker with the values "x","y","z" after every action is made, which i dont want to show up.

I'm a beginner with VBA, so im limited in knowing whether code is overcomplicated
>>
>>39566209
Well to reference what you said is something like

If thisworkbook.sheets("x").range("y").value = "z" then

Not sure what your current code is trying to do but it takes cells of row abcsamerow columns 3 to 5 and checks if they are x,y,z. If so, deletes row abcrow contents from sheet audit.

It seems overly complex, I'm still not fully sure what you are trying to accomplish, what problem you are trying to solve.
>>
>>39566619
the sheet was meant to track changes, but the auto update sub after every action gets listed as a change...after every action. So there would be a lot of repeats of a specific change, which I dont want.

So I let the macros run, but delete the row contents that was just populated if it matches "x", "y", "z".

the 3rd line in your post is exactly what im after. its just that with the last if block, it just deletes any new entry and not just ones with "x","y","z"
>>
>>39566873
To stop repeats, begin your worksheet_change code with

Application.enableevents = false

This will make it so that whatever changes your macro makes to the sheet will not trigger the autoupdate again and again.

Don't forget to set enableevents to true at the end.
>>
>>39567043
I currently have that in the worksheet_change code.

I will check tomorrow if its in the worksheetvaluechange one that auto updates the pivot after every action.

Would you be able to advise on why the if statement in my code isn't sticking to the conditions xyz and instead just deleting every new row, no matter what value's entered?
>>
>>39567133
Can't say without seeing the entire thing, but your conditions are very specific. That means conditions x,y,z all have to be fulfilled exactly. Either it's looking in a place you don't expect or something else is wrong. Tried using the debugger? Put a breakpoint on that line by clicking on it on the left side of the macro editor. It turns brown. Run it and when it stops, you can individually inspect each variable and its contents on that line.
>>
File: Smug+anime+faces_95aba7_5762907.jpg (10KB, 237x212px) Image search: [Google]
Smug+anime+faces_95aba7_5762907.jpg
10KB, 237x212px
>He's using VBA.
>>
>>39567310
Yeah from the debugger, its that if block. Just can't see why its not listening if ive specified the conditions.

>>39567345
Help me, o so superior one
Thread posts: 14
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.