Macro to select Row as well as any particular column

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello,
Sheets("Sheet1").Activate
Columns("D:D").Select
Selection.Replace What:="&", Replacement:="&", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A2").Select

This formula selects and replaces & in the column D
I want it to select the first full row also along with column D
what is the code to be added and where.?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Do you mean you want the replace to work on row 1 & col D?
 
Upvote 0
Do you mean you want the replace to work on row 1 & col D?
There are & in the headings also which I want it to be replaced by &. Earlier there were names which had & in the words in that particular column. Now the headings also have some names containing &.
 
Upvote 0
There are & in the headings also which I want it to be replaced by &. Earlier there were names which had & in the words in that particular column. Now the headings also have some names containing &.
 
Upvote 0
Ok, how about
VBA Code:
Sub Rajesh()
   With Union(Sheets("sheet1").Range("1:1"), Sheets("Sheet1").Range("D:D"))
      .Replace "&amp", "&", xlPart, , False, , False, False
   End With
End Sub
 
Upvote 0
With Union(Sheets("sheet1").Range("1:1"), Sheets("Sheet1").Range("D:D")) .Replace "&amp", "&", xlPart, , False, , False, False End With
Error: subscript out of range
 
Upvote 0
Hello,
Sheets("Sheet1").Activate
Columns("D:D").Select
Selection.Replace What:="&", Replacement:="&", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A2").Select

This formula selects and replaces & in the column D
I want it to select the first full row also along with column D
what is the code to be added and where.?
the column part has been working fine. But since in this project the headings in the first row contain "&" I am not able to import data.
 
Upvote 0
Do you actually have a sheet called sheet1 in the active workbook?
 
Upvote 0
Do you actually have a sheet called sheet1 in the active workbook?
Sorry I changed the sheet name now. but this time I am getting a compile error Syntax error
 
Upvote 0
Do you have the code laid out as per post#5, or in one line like your quote in in post#6?
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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