First Lady Nancy Reagan told a partisan crowd here tonight that if she lived in Virginia she would vote for Republican J. Marshall Coleman for governor.

Mrs. Reagan came to the fund-raiser for Coleman, substituting for her husband who was delivering a nationally televised speech on the budget, to give a strong boost to his candidacy, further tying it to the Reagan presidency.

The effort was so successful that if it hadn't been for the banners hanging from the balcony proclaiming Coleman's candidacy, a visitor who crowded into the ballroom of the John Marshall Hotel here tonight might not have known who the rally was for.

Was it a kickoff of President Reagan's re-election campaign, or had Virginia's senior senator, Harry F. Byrd Jr., finally decided to join the party he has been voting with for so long as an independent?

Mrs. Reagan said the scene reminded her of the campaign trail, with "the banners, the bunting and my husband in another state."

The president had been the scheduled attraction when about 500 people purchased $50 tickets to the rally, and 100 others laid out $2,500 a couple for the dinner that followed. But there were few complaints about the substitution, and campaign sponsors said no tickets had been returned.

If Coleman and his running mates for state office were overshadowed by Mrs. Reagan, glittering in a black and gold suit, or Byrd, the coy conservative who is being wooed by the GOP, Coleman appeared to love the association with the president, and the quarter-of-a-million dollars or so his name attracted.

Just yesterday, Coleman denounced his opponent, Democratic Lt. Gov. Charles S. Robb, for using surrogates to attack him. Today Robb surrogates were at work again. In a full-page advertisement in the Richmond Times-Dispatch, Virginians for Robb, a coalition of former Byrd Democrats who support the president, welcomed Mrs. Reagan. But the ad said that in 1977 when Reagan backed Coleman's opponent for the Republican attorney-general nomination, Coleman had labeled Reagan's support of his opponent "an intrusion."

But tonight, Coleman stood by, silently grinning, as his own surrogates wrapped him even tighter in the security blanket of the popular president.

While most of the rhetoric and applause went to mentions of the president and his program, Mrs. Reagan plugged the Coleman campaign like the good trouper she is.

She urged the partisan audience to "elect a man governor who will keep us going in the right direction . . . I don't want to tell Virginians who to vote for," she said in a soft voice, "but my mother was born in Virginia, and if I lived here, I'd be voting for Marshall Coleman."

She said that as she left the White House, "for about the third time, my husband said, 'I hope they understand' why he was not coming and I said, 'I'm sure they understand.' "

Then, turning to Sen. Byrd, who had introduced her, she added, "When my husband heard that my escort on the trip was going to be Sen. Byrd, he said, 'Tell him he should come over and travel with the Republicans more often.' "

Byrd smiled and nodded as the crowd cheered.

The white-haired Byrd, who hasn't announced whether he will seek reelection next year, and if so, whether he will run as an independent or switch to the GOP, delivered a speech that was the longest and most laudatory of Reagan of the night. He praised Reagan as "the only president in recent years who has made a determined effort to control government spending, which is, in my judgment, essential if our nation is to be preserved."

Byrd didn't even mention Coleman, or Coleman's running mates, lieutenant governor candidate Nathan Miller and attorney general candidate Wyatt Durette, who were also on the stage with him.

Byrd was introduced by former governor Mills E. Godwin, whose party-switching many Republicans would like to see Byrd emulate. Godwin, elected first as a Byrd Democrat and a second time as a Republican, has been lukewarm at best in his support for the current GOP ticket. He also failed to mention Coleman by name, referring to him only as "our attorney general."

Praise for Coleman came largely from his most vocal cheerleader, outgoing Republican Gov. John N. Dalton, who managed to get the crowd to respond "yes" to the challenge, "Are you going to get the job done?"

Even Coleman concentrated his brief remarks on praise for the Reagan administration, and thanking Mrs. Reagan for "your sacrifice in coming here on this important occasion."

After the rally, Mrs. Reagan mingled briefly among the 100 couples who were dining at the hotel's Roof Garden. But before the diners were well into the poached salmon, veal marsala and meringue shells with melba sauce, she and Byrd and GOP National Chairman Richard Richards had boarded the helicopter that had brought them from the White House three hours earlier.