Use macro in different rows

mmackoka

New Member
Joined
Apr 24, 2022
Messages
6
Platform
  1. MacOS
Hi,
I'm to macros and no idea what to do and what do I do wrong. I recorded few different macros for my excel sheet what continuously changing. I have products there and different variations under the products so the idea was that, to select rows and run the correct macro. I think I'm nearly there but when I run the macro it always want to overwrite the data in the row I've created it and I want the data to be written in the same row where I run the macro.
Is there some easy solution let's say add a line in the macro to change the T4 cell to whatever row T column?

Here is one of them:

Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+p
'
Selection.TextToColumns Destination:=Range("T4"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=True, OtherChar:= _
"=", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1)), _
TrailingMinusNumbers:=True
End Sub


Thank you!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi & welcome to MrExcel.
Change Range("T4") to Selection
 
Upvote 0
Hi & welcome to MrExcel.
Change Range("T4") to Selection
Wow! This was super quick, thank you so much!! I was sitting on it all day but couldn't figure it out.
The data I have is in the column J and when I run the macro I would like to have it in T. Is there any quick magic to do that please? I think I will have to start learning excel again. So far I used it like a notebook. Looks like it can do a bit more :)
 
Upvote 0
In that case use Range("T" & Selection.Row)
 
Upvote 0
Thank you again! This is really helpful! I may be able to finish this year what I want :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Me again, and stuck again...

So now I have few rows but always different amount what I would like to select and run the macro on them. Recorded the macro on few rows but of course is not working on other rows...well it's not even working now...I've tried range and selections but no luck. Could you please have a look on it?

Range("U16:X36").Select
ActiveWorkbook.Worksheets("eBay-edit-price-quantity-templa").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("eBay-edit-price-quantity-templa").Sort.SortFields. _
Add2 Key:=Range("U16:U36"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("eBay-edit-price-quantity-templa").Sort.SortFields. _
Add2 Key:=Range("W16:W36"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("eBay-edit-price-quantity-templa").Sort
.SetRange Range("U16:X36")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
 
Upvote 0
As this is a totally different question, it needs a new thread. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top