Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2022, 11:01 PM
Bikram Bikram is offline passing values in function Windows 10 passing values in function Office 2007
Advanced Beginner
passing values in function
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default passing values in function

Hi all members, I am working on a macro where i encountered an error
Code:
Function newreplace(rng2) As Range
Dim e(), f()
e = Array("( ){2,}", "^s", Chr(160), "^t{2,}", "(\([a-z]\)){1,4}")
f = Array("\1", " ", " ", "^t", "\1")
Dim i As Integer
For i = LBound(e) To UBound(e)
With rng2.find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = e(i)
    .Replacement.Text = f(i)
    .MatchWildcards = True
    .Wrap = wdFindStop
End With
rng2.find.Execute Replace:=wdReplaceAll
Next
End Function
Here everything seems to work fine but when I reached the "with rng2.find" line VBA throws an error "424". I couldn't get a hint What did I miss? It would be a great help if someone points out what am I doing wrong and suggests a solution.
Reply With Quote
  #2  
Old 04-18-2022, 03:26 AM
macropod's Avatar
macropod macropod is offline passing values in function Windows 10 passing values in function Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Code:
Function newreplace(rng2 As Range)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-18-2022, 08:42 PM
Bikram Bikram is offline passing values in function Windows 10 passing values in function Office 2007
Advanced Beginner
passing values in function
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default

Thank you, Paul. It worked!!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble converting a sub to function, incl. passing argument and nixing Selection Peterson Word VBA 6 08-19-2021 07:58 PM
passing values in function Using IF Function where logical test is for range of values guciolino Excel 10 02-13-2017 08:05 AM
passing values in function passing variable from one sub to another gbrew584 Excel Programming 10 03-21-2016 12:06 AM
Formula/function to return column names for matching values GiJoe81 Excel 1 06-27-2015 12:13 AM
passing values in function MATCH function and time values hanvyj Excel 2 05-29-2013 12:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft