President Donald Trump shouldn't be bashing Mexico with threatened tariffs, CNBC's Jim Cramer said Friday.

"He should stop beating up" Mexico, Cramer said on "Squawk Box." "They haven't done anything."

Trump announced last week that he would impose a 5% tariff on Mexican imports, beginning Monday, if Mexico doesn't take substantial action to reduce the number of undocumented migrants crossing into the U.S. The tariffs would go up incrementally to as high as 25% in October.

But this isn't a trade issue, the "Mad Money" host said.

"It's about vanity and getting a (border) wall built," Cramer said.

The White House was not immediately available to respond to CNBC's request for comment on Cramer's remarks.

Mexico was the second-largest importer of goods into the U.S. in 2018, according to the Office of U.S. Trade Representative. And the tariffs could reportedly cost U.S. consumers $18.6 billion. Last year, U.S. imports from Mexico surpassed $346.5 billion and exports topped $265 billion.

Cramer has been critical of Trump's tariff moves in the past, saying the move caught him by surprise.

"It is a mistake to use commerce as a weapon against a government that's been happy to cooperate with us on trade," Cramer said last Friday, a day after Trump announced the tariffs.

Top Mexican officials have been meeting with White House officials this week in a bid to stop the tariffs, and talks are set to resume Friday. On Wednesday, Trump tweeted that "Progress is being made, but not nearly enough!"

"I think the president is erratic about this," Cramer said. "Mexico is a good friend of this country."