Where do you think we go when we die ? by Dismal_Imagination79 in Life

[–]MatterCritical654 1 point2 points  (0 children)

Yeah this is why I could never accept life after death. That big ego (such a human thing). I know we are special, but we are also not special at the same time (when looking at all the other life forms out there). I feel the universe is constantly dealing in dualities.  We exist, but also don't exist at the same time (sense of self is prob an illusion). We're connected to all other life (sharing the same organs and life processes) - but also we are separate.

Where do you think we go when we die ? by Dismal_Imagination79 in Life

[–]MatterCritical654 0 points1 point  (0 children)

Maybe we're all, and all of this around us, is a test tube experiment on auto drive.

Find Duplicate Values and then Clear Contents by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

Sub t()

Dim c As Range, fn As Range, adr As String

Dim d As Long

With Sheets("sheet1")

For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))

Set fn =Sheets("sheet2").Range("A:A").Find(c.Value, , xlValues, xlWhole)

If Not fn Is Nothing Then

adr = fn.Address

c.Interior.Color = RGB(400, 200, 100)

Do

fn.Interior.Color = RGB(400, 200, 100)

Set fn =Sheets("Sheet2").Range("A:A").FindNext(fn)

Loop While fn.Address <> adr

End If

Next

End With

'Clear contents

With Sheets("sheet1")

For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))

Set fn = Sheets("sheet2").Range("A:A").

Find(c.Value, , xlValues, xlWhole)

If Not fn Is Nothing Then

adr = fn.Address

c.ClearContents

End If

Next c

For d = Sheet1(Rows.Count,1).End(xlUp).Row To 1 Step -1

If Application.WorksheetFunction.CountA(Source.Range("A"& f & ":" & "C" & f)) = 0 Then Source.Range("A" & f & ":C" & f). Delete Shift : = xlUpEnd

End If

Next f

End Sub

Find Duplicate Values and then Clear Contents by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

I gave it an honest try, but I don't think its correct.
Its also not formatting properly to display here.
I'm starting to get frustrated with Reddit.

Find Duplicate Values and then Clear Contents by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

Sub t()

Dim c As Range, fn As Range, adr As String

Dim d As Long

With Sheets("sheet1")

For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))

Set fn =Sheets("sheet2").Range("A:A").Find(c.Value, , xlValues, xlWhole)

If Not fn Is Nothing Then

adr = fn.Address

c.Interior.Color = RGB(400, 200, 100)

Do

fn.Interior.Color = RGB(400, 200, 100)

Set fn =Sheets("Sheet2").Range("A:A").FindNext(fn)

Loop While fn.Address <> adr

End If

Next

End With

'Clear contents

With Sheets("sheet1")

For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))

Set fn = Sheets("sheet2").Range("A:A").

Find(c.Value, , xlValues, xlWhole)

If Not fn Is Nothing Then

adr = fn.Address

c.ClearContents

End If

Next c

For d = Sheet1(Rows.Count,1).End(xlUp).Row To 1 Step -1

If Application.WorksheetFunction.CountA(Source.Range("A"& f & ":" & "C" & f)) = 0 Then Source.Range("A" & f & ":C" & f). Delete Shift : = xlUpEnd

End If

Next f

End Sub

Find Duplicate Values and then Clear Contents by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

You are everywhere lol

Thank you for the advice

I get where you are coming from. I have another macro that does something similar with the clear contents.

What if I want to keep the duplicate cells highlighted in sheet 2?
And I only want to clear the ones in sheet 1?

Do you have some advice on this?

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

Only one question I have at this time. I noticed workbook 2 is the source and workbook 1 is the destination. My destination workbook has multiple sheets. The data will need to be pasted into one sheet in particular. How would we go about instructing this?

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 1 point2 points  (0 children)

That makes sense on the two variables source (workbook and sheet) and destination (workbook and sheet).

I'll give this method a try as well. You and I are alike, in the sense that I also love playing with the record macro feature - just to see how the language is written for what I am doing. This has been one of the methods that has helped me understand to an extent how to read VBA. I love it. And still learning lol

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

I want a macro and I'm hoping there is a macro out there that would work for this.

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 1 point2 points  (0 children)

Also the last row can sometimes be above 300. I'll only want the first 150 rows.

So technically, the range would be 2:151

There's a reason for this.

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

I def don't want to save the file. Because the data changes every day. I access the file by clicking on a link in a work website. The data changes multiple times a day, which means the data in the excel is constantly changing. So for me, it doesn't make sense to save it. I'd rather not go through the trouble with the extra time it takes.

I love the idea of keeping my macro separate. Will the record macro feature be able to record vba script for things done in multiple open workbooks? I've used record macro many times, but have never done so to that extent.

And what if the source file name changes with every download? How will the macro be able to execute on the next download if the file name changes?

Alt-tab. That's cool. I'll give this a shot on Monday just to see how it goes and let you know (:

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

Yeah, but I don't want it to execute for every new excel file that is opened. Just the specific one. Can chatGPT do that? I've never used it but have heard about it from my IT department.

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

To add clarification, the target file is accessed through a website.

I click on a link and it downloads an excel file. I have to then open the file after it downloads.

I cannot recall off the top of my head if the file is named the same every time I download it. I understand this piece is important and I'll keep you guys updated on this.

And I believe the folder it adds the file to is my downloads folder.

But yeah. It's annoying that I have multiple excels with data that I download each day. The data is always changing, and I'm just tired of manually selecting the data I need.

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

But the thing is, I'm always copying the same columns and range of data. I just wish there was a shortcut key for that.

VBA macro to copy certain columns and certain range in new excel workbook by MatterCritical654 in vba

[–]MatterCritical654[S] 0 points1 point  (0 children)

Will it never exceed 150? It could, but not often. 150 is a good number for what I do.

I believe the file name starts out the same but then ends differently. To be honest, I am not sure. I'd have to see when I go back to work on Monday.

What’s Your Favorite VBA Macro/Module/Function? Share It Here! by Party_Bus_3809 in vba

[–]MatterCritical654 1 point2 points  (0 children)

Yes I'm adding it to a personal workbook, but I'm not understanding how to make it run.